Short, Simple and concise | C++
\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        unordered_map<int, int> m;\n        \n        int i = 0, j = 0, sum = 0
```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        unordered_map<int, int> m;\n        \n        int i = 0, j = 0, sum = 0, ans = 0;\n        while(j < nums.size()) {\n            m[nums[j]]++;\n            sum += nums[j];\n            \n            if(m.size() == j - i + 1) ans = max(ans, sum);\n            \n            while(m.size() < j - i + 1) {\n                m[nums[i]]--;\n                sum -= nums[i];\n                if(!m[nums[i]]) m.erase(nums[i]);\n                i++;\n            }\n            j++;\n        }\n        \n        return ans;\n    }\n};\n```
['Two Pointers', 'C', 'Sliding Window']