C++ | O(N) | Two pointers & Hash-Set
\n\n\nint maximumUniqueSubarray(vector<int>& nums) {\n        int ret=0, sum=0, i=0, n=nums.size();\n        vector<bool> found(10001,false);\n        for(int j
![image](https://assets.leetcode.com/users/images/b5ca6464-6779-4933-bac1-86ffe01f07be_1655026943.2890792.png)\n\n```\nint maximumUniqueSubarray(vector<int>& nums) {\n        int ret=0, sum=0, i=0, n=nums.size();\n        vector<bool> found(10001,false);\n        for(int j=0; j<n; j++){\n            sum += nums[j];\n            if(!found[nums[j]]){\n                found[nums[j]] = true;\n            }\n            else {\n                while(nums[i]!=nums[j]){\n                    sum -= nums[i];\n                    found[nums[i++]] = false;\n                }\n                sum-=nums[i];\n                i++;\n            }\n            ret = max(ret, sum);\n        }\n        return ret;\n    }\n```
['Two Pointers']