Python, prefix sum O(N)
First calculate the prefix sum, then do a single pass recording last seen positions for each element. \nThese will serve as breaking points for the array.\n\nde
First calculate the prefix sum, then do a single pass recording last seen positions for each element. \nThese will serve as breaking points for the array.\n```\ndef maximumUniqueSubarray(self, nums: List[int]) -> int:\n\tprefix = [0]\n\tfor i in range(len(nums)):\n\t\tprefix += [prefix[-1] + nums[i]]\n\n\tlastpos = {}\n\tmaxsum = 0\n\tleft = 0\n\tfor i, n in enumerate(nums):\n\t\tif n in lastpos:\n\t\t\tleft = max(left, lastpos[n])\n\t\tlastpos[n] = i+1\n\t\tmaxsum = max(maxsum, prefix[i+1] - prefix[left])\n\n\treturn maxsum\n```
['Prefix Sum', 'Python', 'Python3']