Given an integer array nums and an integer k, return true if nums has a good subarray, and false otherwise. A good subarray has length at least two and its sum is a multiple of k. A subarray is a contiguous part of the array, and 0 counts as a multiple of every k.
Given an integer array nums and an integer k, return true if nums has a good subarray, and false otherwise. A good subarray has length at least two and its sum is a multiple of k. A subarray is a contiguous part of the array, and 0 counts as a multiple of every k.
Example 1:
Input: {"nums":[23,2,4,6,7],"k":6}
Output: true
Constraints:
1≤nums.length≤105
0≤nums[i]≤109
0≤∑nums[i]≤231−1
1≤k≤231−1
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[23,2,4,6,7],"k":6}
Seed the map with remainder 0 at index -1: the empty prefix has sum 0, so a prefix that is itself a multiple of 6 can match it.