1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
Содержание
class Solution:
def maxNonOverlapping(self, nums: List[int], target: int) -> int:
res = 0
i, n = 0, len(nums)
while i < n:
s = 0
vis = {0}
while i < n:
s += nums[i]
if s - target in vis:
res += 1
break
i += 1
vis.add(s)
i += 1
return res