✔C++|Sliding Window|Hash Table|O(N)🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nIntuition is simple if u done some sliding window problems I suggest doing in same way 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIntuition is simple if u done some sliding window problems I suggest doing in same way as u have done those because there are little implementations techniques a liitle different than one another but idea is same or best is what is hitting your mind mostly . So I basically do these problems using a map and checking when there is a duplicate start removing it from map and also decremnt its value form sum. \nU can checkout this problem quite similar to this and many other also : \n- [https://leetcode.com/problems/longest-substring-without-repeating-characters/description/]()\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSo using  Sliding Window These are the steps:\n- Insert one by one in map and also check a constion along with this .\n- Condition is if mp[arr[i]] is >1 i.e is a duplicate so remove it .\n- Also decrease its value from sum variable.\n- Keep a maxi varaible for maximum window. \n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n**Implementation I**\n```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& arr) {\n        int maxi=0, j=0, n=arr.size(),req=0,sum=0;\n        unordered_map<int,int>mp;\n        for(int i=0;i<n;i++){\n            mp[arr[i]]++;\n            sum+=arr[i];\n            while(mp[arr[i]]>1){\n                sum-=arr[j];\n                --mp[arr[j]];\n                j++;\n            }\n           maxi=max(sum,maxi);\n        }\n        return maxi;\n    }\n};\n```\n**Implementation II**\n```\nint maximumUniqueSubarray(vector<int>& arr) {\n        int maxi=0, j=0, n=arr.size(),req=0,sum=0;\n        unordered_map<int,int>mp;\n        for(int i=0;i<n;i++){\n            mp[arr[i]]++;\n            sum+=arr[i];\n            while((i-j+1)>mp.size()){\n                sum-=arr[j];\n                if(--mp[arr[j]]==0)mp.erase(arr[j]);\n                j++;\n            }\n           maxi=max(sum,maxi);\n        }\n        return maxi;\n```
['Array', 'Hash Table', 'Sliding Window', 'C++']