Question
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.
https://leetcode.com/problems/continuous-subarray-sum/
- Solution1
1 | class Solution { |
Complexity:
Time complexity: O( n)
Space complexity: O(n)