```
class Solution(object):
def maxSubArrayLen(self, nums, k):
last, sums, d, res = 0, 0, {0: 0}, 0
for i, num in enumerate(nums):
sums += num + last
if sums - k in d: res = max(res, i - d[sums - k] + 1)
if sums not in d: d[sums] = i + 1
return res
# 35 / 35 test cases passed.
# Status: Accepted
# Runtime: 84 ms
```