Binary Subarrays With Sum
n an arrayA
of0
s and1
s, how manynon-emptysubarrays have sumS
?
Example 1:
Note:
分析
用presum,一个map存sum:count, 每次+= map(cursum-target)
map初始0:1 因为要考虑sum=target的情况
2指针没做出来
Last updated
n an arrayA
of0
s and1
s, how manynon-emptysubarrays have sumS
?
Example 1:
Note:
分析
用presum,一个map存sum:count, 每次+= map(cursum-target)
map初始0:1 因为要考虑sum=target的情况
2指针没做出来
Last updated