Python | sliding window (two pointers) + hash set | with comments
How I approach this problem:\n1. Use a hash set to track the numbers in the current window. \n2. Use curSum to track the sum of the number in the current window
How I approach this problem:\n1. Use a hash set to track the numbers in the current ```window```. \n2. Use ```curSum``` to track the sum of the number in the current window.\n3. Use two pointers ```l``` and ```r``` to expand and shrink the sliding window.\n4. Move ```r```. When encounter duplicate numbers in the window, move the ```l``` until the current window has no duplicates.\n5. Keep updating hashset ```window``` and ```curSum``` when doing above step.\n\nBelow is my code with comments. Feel free to ask if you have any questions!\n\n```\nclass Solution:\n    def maximumUniqueSubarray(self, nums: List[int]) -> int:\n        window = set() # a hash set to track the numbers in the current window\n        res = 0\n        curSum = 0 # track the sum of the numbers in the current window\n        l = 0 # initialize the left pointer of the sliding window\n        \n        for r in range(len(nums)): # move the right pointer of the sliding window\n            \n            # move the left pointer until the current window has no duplicate numbers\n            while nums[r] in window and l < r:\n                window.remove(nums[l]) # remove the left-most number\n                curSum -= nums[l] # subtract the removed number from curSum \n                l += 1\n            \n            # if no duplicate numbers in the window   \n            window.add(nums[r]) # add the current number\n            curSum += nums[r] # add the number to curSum\n            \n            res = max(res, curSum) # update the result\n            \n        return res\n```
['Two Pointers', 'Sliding Window', 'Python']