1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/连续的子数组和 [continuous-subarray-sum].html
2022-03-29 12:43:11 +08:00

47 lines
1.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,编写一个函数来判断该数组是否含有同时满足下述条件的连续子数组:</p>
<ul>
<li>子数组大小 <strong>至少为 2</strong> ,且</li>
<li>子数组元素总和为 <code>k</code> 的倍数。</li>
</ul>
<p>如果存在,返回 <code>true</code> ;否则,返回 <code>false</code></p>
<p>如果存在一个整数 <code>n</code> ,令整数 <code>x</code> 符合 <code>x = n * k</code> ,则称 <code>x</code><code>k</code> 的一个倍数。<code>0</code> 始终视为 <code>k</code> 的一个倍数。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [23<u>,2,4</u>,6,7], k = 6
<strong>输出:</strong>true
<strong>解释:</strong>[2,4] 是一个大小为 2 的子数组,并且和为 6 。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [<u>23,2,6,4,7</u>], k = 6
<strong>输出:</strong>true
<strong>解释:</strong>[23, 2, 6, 4, 7] 是大小为 5 的子数组,并且和为 42 。
42 是 6 的倍数,因为 42 = 7 * 6 且 7 是一个整数。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [23,2,6,4,7], k = 13
<strong>输出:</strong>false
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>
<li><code>0 <= sum(nums[i]) <= 2<sup>31</sup> - 1</code></li>
<li><code>1 <= k <= 2<sup>31</sup> - 1</code></li>
</ul>