forked from YaxeZhang/Just-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontinuous-subarray-sum.md
More file actions
28 lines (20 loc) · 893 Bytes
/
continuous-subarray-sum.md
File metadata and controls
28 lines (20 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<p>Given a list of <b>non-negative</b> numbers and a target <b>integer</b> k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of <b>k</b>, that is, sums up to n*k where n is also an <b>integer</b>.</p>
<p> </p>
<p><b>Example 1:</b></p>
<pre>
<b>Input:</b> [23, 2, 4, 6, 7], k=6
<b>Output:</b> True
<b>Explanation:</b> Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
</pre>
<p><b>Example 2:</b></p>
<pre>
<b>Input:</b> [23, 2, 6, 4, 7], k=6
<b>Output:</b> True
<b>Explanation:</b> Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
</pre>
<p> </p>
<p><b>Note:</b></p>
<ol>
<li>The length of the array won't exceed 10,000.</li>
<li>You may assume the sum of all the numbers is in the range of a signed 32-bit integer.</li>
</ol>