Untitled
plain_text
a month ago
361 B
2
Indexable
Never
#python solution class Solution: def subarraySum(self, nums: List[int], k: int) -> int: dic=collections.defaultdict(lambda: 0) res=0 tot=0 for i in nums: tot +=i if tot==k: res+=1 if (tot-k) in dic: res+=dic[tot-k] dic[tot]+=1 return res