mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part3
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<p>Given a binary array <code>nums</code> and an integer <code>goal</code>, return <em>the number of non-empty <strong>subarrays</strong> with a sum</em> <code>goal</code>.</p>
|
||||
|
||||
|
||||
|
||||
<p>A <strong>subarray</strong> is a contiguous part of the array.</p>
|
||||
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
<strong>Input:</strong> nums = [1,0,1,0,1], goal = 2
|
||||
|
||||
<strong>Output:</strong> 4
|
||||
|
||||
<strong>Explanation:</strong> The 4 subarrays are bolded and underlined below:
|
||||
|
||||
[<u><strong>1,0,1</strong></u>,0,1]
|
||||
|
||||
[<u><strong>1,0,1,0</strong></u>,1]
|
||||
|
||||
[1,<u><strong>0,1,0,1</strong></u>]
|
||||
|
||||
[1,0,<u><strong>1,0,1</strong></u>]
|
||||
|
||||
</pre>
|
||||
|
Reference in New Issue
Block a user