Description

Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least 2 that sums to a multiple of k.

Examples

Input:nums = [23,2,4,6,7], k = 6
Output:true
Explanation:

[2,4] sums to 6.

Input:nums = [23,2,6,4,7], k = 6
Output:true
Explanation:

For nums = [23,2,6,4,7], k = 6, the answer is true because the continuous subarray sum condition is satisfied.

Input:nums = [5,0,0], k = 3
Output:true
Explanation:

The subarray [0,0] has a sum of 0, which is a multiple of 3 (0 = 3 × 0). This demonstrates that zero is considered a multiple of any non-zero integer.

Constraints

  • 1 ≤ nums.length ≤ 10⁵

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!