Simple two pointers code ,[O(n) time and memory complexity ]
\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int frq[10005]={0};\n        int l=0,r=0,mx=0,cur_sum=0;\n        while
```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int frq[10005]={0};\n        int l=0,r=0,mx=0,cur_sum=0;\n        while(l<nums.size()){\n            while(r<nums.size()&&!frq[nums[r]]){\n                cur_sum+=nums[r];\n                ++frq[nums[r++]];\n            }\n            mx=max(mx,cur_sum);\n            cur_sum-=nums[l];\n            --frq[nums[l++]];\n        }\n        return mx;\n    }\n};\n```
['Two Pointers']