Algorithm
Initialize sum←0,hashMap[0]←0,i←0sum \leftarrow 0, hashMap[0] \leftarrow 0, i \leftarrow 0sum←0,hashMap[0]←0,i←0.
sum+=nums[i]sum += nums[i]sum+=nums[i].
If hashMaphashMaphashMap does not contain key sum%ksum \% ksum%k (this remainder modulo kkk occurs for the first time) then hashMap[sum%k]←i+1hashMap[sum \% k] \leftarrow i + 1hashMap[sum%k]←i+1, go to 5.
If hashMap[sum%k]<ihashMap[sum \% k] < ihashMap[sum%k]<i (the subarray size is at least two) return true.
i+=1i += 1i+=1.
If i<nums.lengthi < nums.lengthi<nums.length go to 2.
Return false.
Initialize sum←0,hashMap[0]←0,i←0sum \leftarrow 0, hashMap[0] \leftarrow 0, i \leftarrow 0sum←0,hashMap[0]←0,i←0.
sum+=nums[i]sum += nums[i]sum+=nums[i].
If hashMaphashMaphashMap does not contain key sum%ksum \% ksum%k (this remainder modulo kkk occurs for the first time) then hashMap[sum%k]←i+1hashMap[sum \% k] \leftarrow i + 1hashMap[sum%k]←i+1, go to 5.
If hashMap[sum%k]<ihashMap[sum \% k] < ihashMap[sum%k]<i (the subarray size is at least two) return true.
i+=1i += 1i+=1.
If i<nums.lengthi < nums.lengthi<nums.length go to 2.
Return false.
Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise.
An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.
An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.