C++ || Easy approach || Sliding Window & Hashmap
simply using sliding window technique with map and meanwhile calculatin the sum \nif anywhere found repeated element the slide the window ahead.\n\nupvote if it
simply using sliding window technique with map and meanwhile calculatin the sum \nif anywhere found repeated element the slide the window ahead.\n\nupvote if it helped you.\n```\n int maximumUniqueSubarray(vector<int>& nums) {\n        unordered_map<int ,int> map;\n        int i=0,j=0;\n        int sum=0;\n        int ans=INT_MIN;\n        while(j<nums.size())\n        {\n            sum+=nums[j];\n            map[nums[j]]++;\n            \n            if(map.size()==j-i+1)\n            {\n                ans=max(sum,ans);\n            }\n            else if(j-i+1>map.size())\n            {\n                while(i<=j && j-i+1>map.size())\n                {\n                    sum-=nums[i];\n                    map[nums[i]]--;\n                    if(map[nums[i]]==0)\n                    {\n                        map.erase(nums[i]);\n                    }\n                    i++;\n                }\n                \n                if(j-i+1==map.size())\n                {\n                    ans=max(ans,sum);\n                }\n            }\n            j++;\n        }\n        return ans;\n        \n    }```
['Two Pointers', 'C', 'Sliding Window']