You are given an integer array nums and an integer k.
Your task is to determine whether there exists a continuous subarray of at least two elements such that the sum of the subarray is a multiple of k.
In other words, find if there exists a subarray [i, j] (where j - i >= 1) such that:
Notes:
A subarray must consist of contiguous elements in the array.
Any number is a multiple of k if it can be expressed as n * k for some integer n.
Zero (0) is always considered a multiple of k.
Input: nums = [23, 2, 4, 6, 7], k = 6
Output: true
Explanation:
Subarray [2, 4] has a sum of 6, which is a multiple of 6.
Input: nums = [23, 2, 6, 4, 7], k = 6
Output: true
Explanation:
The entire array sums to 42, and 42 % 6 == 0.
Input: nums = [23, 2, 6, 4, 7], k = 13
Output: false
Explanation:
No subarray has a sum that is a multiple of 13.
Accepted:
Submission: