Skip to content

Latest commit

 

History

History
69 lines (35 loc) · 1.13 KB

File metadata and controls

69 lines (35 loc) · 1.13 KB

中文文档

Description

In an array A of 0s and 1s, how many non-empty subarrays have sum S?

 

Example 1:

Input: A = [1,0,1,0,1], S = 2

Output: 4

Explanation: 

The 4 subarrays are bolded below:

[1,0,1,0,1]

[1,0,1,0,1]

[1,0,1,0,1]

[1,0,1,0,1]

 

Note:

    <li><code>A.length &lt;= 30000</code></li>
    
    <li><code>0 &lt;= S &lt;= A.length</code></li>
    
    <li><code>A[i]</code>&nbsp;is either <code>0</code>&nbsp;or <code>1</code>.</li>
    

Solutions

Python3

Java

...