✅  Python Easy 2 approaches
\u2714\uFE0FSolution I - Two pointers using Counter\n\nclass Solution:\n    def maximumUniqueSubarray(self, nums: List[int]) -> int:\n        counter=defaultdic
## \u2714\uFE0F*Solution I - Two pointers using Counter*\n```\nclass Solution:\n    def maximumUniqueSubarray(self, nums: List[int]) -> int:\n        counter=defaultdict(int) # track count of  elements in the window\n        res=i=tot=0\n\t\t\n        for j in range(len(nums)):\n            x=nums[j]   \n            tot+=x\n            counter[x]+=1\n            # adjust the left bound of sliding window until you get all unique elements\n            while i < j and counter[x]>1: \n                counter[nums[i]]-=1\n                tot-=nums[i]\n                i+=1\n            \n            res=max(res, tot)            \n        return res\n```\n\n## \u2714\uFE0F*Solution II - Two pointers using Visited*\n\n```\nclass Solution:\n    def maximumUniqueSubarray(self, nums: List[int]) -> int:\n        seen=set() # track visited elements in the window\n        res=i=tot=0\n        for j in range(len(nums)):\n            x=nums[j]                   \n\t\t\t # adjust the left bound of sliding window until you get all unique elements\n            while i < j and x in seen: \n                seen.remove(nums[i])\n                tot-=nums[i]\n                i+=1                        \n            tot+=x\n            seen.add(x)\n            res=max(res, tot)            \n        return res\n```\n\n**Time - O(n)**\n**Space - O(k)** - where` k` is number of unique elements in input `nums`.\n\n\n---\n\n\n***Please upvote if you find it useful***
['Python', 'Python3']