class Solution:
TC: O(len(nums)
SC: O(len(nums)
def maxSubArrayLen(self, nums: List[int], k: int) -> int:
Dict = collections.defaultdict(list)
Dict[0].append(-1)
preSum = 0
res = 0
for i in range(len(nums)):
preSum += nums[i]
Dict[preSum].append(i)
if preSum - k in Dict:
Len = i - Dict[preSum-k][0]
res = max(res, Len)
return res