class Solution:
def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int:
if not timeSeries:
return 0
res = 0
for i in range(len(timeSeries)-1):
if timeSeries[i+1] - timeSeries[i] < duration:
res += timeSeries[i+1] - timeSeries[i]
else:
res += duration
return res+duration
class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:
res = 0
sum1 = 0
dict1 = {0:1}
for i in range(len(nums)):
sum1 += nums[i]
if sum1-k in dict1:
res += dict1[sum1-k]
if sum1 not in dict1:
dict1[sum1] = 1
else:
dict1[sum1] += 1
return res