continuous subarray sum

🏠
 1 nums = [23, 2, 4, 6, 7]
 2 k = 6
 3 
 4 class Solution:
 5     def checkSubarraySum(self, nums, k):
 6         n = len(nums)
 7         sums = [0]*n
 8         sums[0] = nums[0]
 9         for i in range(n):
10             sums[i] = sums[i - 1] + nums[i]
11         for i in range(n):
12             for j in range(i, n):
13                 if (j - i) >= 2:
14                     s = sums[j] - sums[i] + nums[i]
15                     if s == k or (k == s == 0) or (k != 0 and s % k == 0):
16                         return True
17         return False
18 
19 s = Solution().checkSubarraySum(nums, k)
20 print(s)