title | tags | categories | author | comments | updated | permalink | mathjax | top | description | date | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
[0930] 和相同的二元子数组 |
|
|
张学志 |
true |
false |
false |
false |
... |
2019-12-31 16:15:30 -0800 |
在由若干 0
和 1
组成的数组 A
中,有多少个和为 S
的非空子数组。
示例:
输入:A = [1,0,1,0,1], S = 2 输出:4 解释: 如下面黑体所示,有 4 个满足题目要求的子数组: [1,0,1,0,1] [1,0,1,0,1] [1,0,1,0,1] [1,0,1,0,1]
提示:
A.length <= 30000
0 <= S <= A.length
A[i]
为0
或1
Related Topics
class Solution {
public:
int numSubarraysWithSum(vector<int>& A, int S) {
}
};