1695. Maximum Erasure Value
On This Page
class Solution:
def maximumUniqueSubarray(self, nums: List[int]) -> int:
d = defaultdict(int)
s = list(accumulate(nums, initial=0))
res = j = 0
for i, v in enumerate(nums, 1):
j = max(j, d[v])
res = max(res, s[i] - s[j])
d[v] = i
return res