✅ C++ | Sliding Window | Hashmap | O(N)
\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int i=0,j=0,sum=0,res=0;\n        unordered_map<int,int> mp;\n        w
```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int i=0,j=0,sum=0,res=0;\n        unordered_map<int,int> mp;\n        while(j<nums.size()){\n            if(mp[nums[j]]){ // nums[j] is already there in the window\n                while(mp[nums[j]]){ // until the occurrence of nums[j] becomes 0, reduce the window from front\n                    mp[nums[i]]--;\n                    sum-=nums[i];\n                    i++;\n                }\n            }\n            else{ // nums[j] is not there in the window, so put it into the window\n                sum+=nums[j];\n                res=max(res,sum); // update the result with maximum sum value\n                mp[nums[j]]++;\n                j++;\n            }\n        }\n        return res;\n    }\n};\n```\n**If you like this, Do Upvote!**
['Two Pointers', 'C', 'Sliding Window']