---
description: LeetCode 523
---

# Continuous Subarray Sum

```python
class Solution:
    def checkSubarraySum(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: bool
        """
        if k == 0: return '00' in ''.join(map(str,nums))

        s = {0}
        cSum = [0] * len(nums)
        cSum[0] = nums[0]
        
        """
        [23,  2,  4,  6,  7]  k = 6
        [23,  0,  0,  0,  0]
             25   29  35  42
        
         5   1    5    5   0
        """
        
        for i in range(1,len(nums)):
            cSum[i] = cSum[i-1] + nums[i]
            if cSum[i] % k in s: 
                return True
            s.add(cSum[i-1]%k)
        return False
```
