Sliding Window || O(N) || HashMap
\nclass Solution {\n   public:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int n = nums.size(), l = 0, r = 0, sum = 0, maxSum = 0;\n        uno
```\nclass Solution {\n   public:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int n = nums.size(), l = 0, r = 0, sum = 0, maxSum = 0;\n        unordered_map<int, int> seen;\n\n        while (r < n) {\n            if (seen.count(nums[r]) == 0) {\n                seen[nums[l]]--;\n                sum -= nums[l++];\n            } else {\n                seen[nums[r]]++;\n                sum += nums[r++];\n                maxSum = max(maxSum, sum);\n            }\n        }\n        return maxSum;\n    }\n};\n```
[]