Class Solution
java.lang.Object
g0501_0600.s0523_continuous_subarray_sum.Solution
523 - Continuous Subarray Sum.<p>Medium</p>
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <code>true</code> <em>if</em> <code>nums</code> <em>has a continuous subarray of size <strong>at least two</strong> whose elements sum up to a multiple of</em> <code>k</code><em>, or</em> <code>false</code> <em>otherwise</em>.</p>
<p>An integer <code>x</code> is a multiple of <code>k</code> if there exists an integer <code>n</code> such that <code>x = n * k</code>. <code>0</code> is <strong>always</strong> a multiple of <code>k</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [23,2,4,6,7], k = 6</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> [2, 4] is a continuous subarray of size 2 whose elements sum up to 6.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [23,2,6,4,7], k = 6</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> [23, 2, 6, 4, 7] is an continuous subarray of size 5 whose elements sum up to 42. 42 is a multiple of 6 because 42 = 7 * 6 and 7 is an integer.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [23,2,6,4,7], k = 13</p>
<p><strong>Output:</strong> false</p>
<p><strong>Constraints:</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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
checkSubarraySum
public boolean checkSubarraySum(int[] nums, int k)
-