✅C++ | Easy Sliding Window Approach!!
This question is similar to: https://leetcode.com/problems/longest-substring-without-repeating-characters/\n\nCode with comments:\n\nclass Solution {\npublic:\n
This question is similar to: https://leetcode.com/problems/longest-substring-without-repeating-characters/\n\n**Code with comments:**\n```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        //finding subarray(with unique elements) with maximum score\n        int score = -1;\n        vector<int> map(1e4+1, -1); //stores index of the elements\n        \n        \n        //make prefix sum to get score\n        vector<int> prefixSum;\n        int sum = 0;\n        for(int it: nums){\n            sum+= it;\n            // cout<<sum<<endl;\n            prefixSum.push_back(sum);\n        }\n        \n        //finding subarray(with unique elements) with maximum score\n        int start = 0;\n        for(int i=0; i<nums.size(); i++){\n            if(map[nums[i]] != -1){ //if element repeats in nums, update start\n                start = max(start, map[nums[i]]+1);\n            }\n            \n            map[nums[i]] = i;   //update index\n            // cout<<nums[i] << " "<< map[nums[i]]<<endl;\n            //get max score\n            int left = (start==0)? 0: prefixSum[start-1];\n            // cout<<left<<endl;\n            score = max(score, prefixSum[i]- left);  \n        }\n        \n        return score;\n    }\n};\n```\n\nTC = O(N)\nSC = O(N)\n\n**Please do upvote if you like the solution:)**
['Two Pointers', 'C', 'Sliding Window']