LinkedIn | Best Solution | Sliding Window | Readable code | C++ | O(N)
\nint maximumUniqueSubarray(vector<int>& nums) {\n        int N = nums.size(), left = 0, right = 0;\n        int currsum = 0, maxsum = 0;\n        bool duplicat
```\nint maximumUniqueSubarray(vector<int>& nums) {\n        int N = nums.size(), left = 0, right = 0;\n        int currsum = 0, maxsum = 0;\n        bool duplicateExists = false;\n        \n        unordered_map <int,int> freq;\n        \n        while(right < N){\n            int num = nums[right];\n            freq[num]++;\n            currsum = currsum + num;\n            \n            if(freq[num] > 1) duplicateExists = true;\n            \n            while(duplicateExists){\n                num = nums[left];\n                if(freq[num] > 1) duplicateExists = false;\n                --freq[num];\n                currsum = currsum - num;\n                left++;\n            }\n            maxsum = max(maxsum,currsum);\n            right++;\n        }\n        return maxsum;\n    }\n```
['C', 'Sliding Window']