mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
30 lines
793 B
HTML
30 lines
793 B
HTML
<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,请你统计并返回 <em>该数组中和为 <code>k</code><strong> </strong>的子数组的个数 </em>。</p>
|
||
|
||
<p>子数组是数组中元素的连续非空序列。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [1,1,1], k = 2
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [1,2,3], k = 3
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 2 * 10<sup>4</sup></code></li>
|
||
<li><code>-1000 <= nums[i] <= 1000</code></li>
|
||
<li><code>-10<sup>7</sup> <= k <= 10<sup>7</sup></code></li>
|
||
</ul>
|