C++| Comments | Clean and small code | 2 pointer
\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& a) {\n        int ans=0;\n        \n        auto it=a.insert(a.begin(),0); //Make 1-base
```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& a) {\n        int ans=0;\n        \n        auto it=a.insert(a.begin(),0); //Make 1-based indexing \n        \n        int st=0, n=a.size()-1, i; //st->is start pointer of each unique window \n        \n        int vis[10001]={0}; // Maintains last index of each a[i]\n        \n        int s=0;\n        st=1;\n        for(i=1;i<=n;i++){\n            s+=a[i];\n           \n            while(st<=vis[a[i]])s-=a[st++]; //shrink window to make it unique again\n                  \n            vis[a[i]]=i;\n            ans=max(ans,s);\n          \n        }\n        \n        return ans;\n    }\n};\n\n/*   some testcases \n[4,2,4,5,6]\n[5,2,1,2,5,2,1,2,5]\n[1,2,3,4,5]\n[1,2,2,1,2,3,1,3,5,6,1,7,1]\n[1,2,3,4]\n[1]\n[1,2]\n[3,4]\n*/\n```
[]