Continuous Subarray Sum Multiple
Problem statement
Given an integer array nums and a positive integer k, return whether some contiguous subarray has at least two elements and a sum that is a multiple of k.
A multiple is an integer times k. Zero is a multiple of every positive k.
Function
checkSubarraySum(nums: int[], k: int) → booleanExamples
Example 1
nums = [23,2,4,6,7]k = 6return = trueThe adjacent values2 and4 sum to6.
Example 2
nums = [23,2,6,4,7]k = 6return = trueThe whole array sums to42, a multiple of6.
Example 3
nums = [23,2,6,4,7]k = 13return = falseNo subarray of length at least two has a sum divisible by13.
Constraints
1 <= nums.length <= 100000.0 <= nums[i] <= 1000000000.0 <= sum(nums) <= 2147483647.1 <= k <= 2147483647.