C++ | 106ms[O(n)] & 89 MB[O(|a[i]|)] (100%/99.9%) | two - pointer | explanation
\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        bool DP[10001]={};\n        int ans=0,r=0,tmp=0;\n        for(int i=0;i
```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        bool DP[10001]={};\n        int ans=0,r=0,tmp=0;\n        for(int i=0;i<nums.size();++i){\n            while(r<nums.size()&&!DP[nums[r]]){\n                DP[nums[r]]=1;\n                tmp+=nums[r++];\n            }\n            ans=max(ans,tmp);\n            if(r>=nums.size()-1)return ans;\n            DP[nums[i]]=0;\n            tmp-=nums[i];\n        }\n        return ans;\n    }\n};\n```\n1.use boolean array to record nums.\n2.r means the right pointer ,iterating to the rightest point it can be.\n3.tmp means the sum for every i to ri  ,ans = max(tmp_i).\n4.when r >= nums.size() - 1 ,the max answer has been found.\n5.left pointer is i.
['Two Pointers', 'C']