Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up to n*k where n is also an integer.
Example 1:
Example 2:
Note:
The length of the array won’t exceed 10,000.
You may assume the sum of all the numbers is in the range of a signed 32-bit integer.
解法1:O(N^2)
Subarray Sum的题目考虑用prefix sum解决,先计算每一个prefix sum,然后再遍历每一个subarray来寻找满足条件的最大答案。
C++
Java