Search topics...

Continuous Subarray Sum

medium
arrayTime: O(n)Space: O(n)Frequency: 4

Given an integer array and an integer k, return true if the array has a continuous subarray of size at least two whose elements sum up to a multiple of k.

Example 1:

Input: nums = [23, 2, 4, 6, 7], k = 6
Output: true
Explanation: [2, 4] sums to 6, which is a multiple of 6.

Example 2:

Input: nums = [23, 2, 6, 4, 7], k = 13
Output: false
hash-mapprefix-sum