C++ Sliding Window and Set
The idea here is to always have a subarray with no duplicate element. This is where set comes into picture to store the elements from i to j.\nThis will be more
The idea here is to always have a subarray with no duplicate element. This is where `set` comes into picture to store the elements from `i` to `j`.\nThis will be more clear from the code:\n```\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int sum=0,curr=0;\n        unordered_set<int> s;\n        int i=0,j=0,n=nums.size();\n        while(i<n&&j<n){\n            if(s.find(nums[j])==s.end()){\n                curr+=nums[j];\n                s.insert(nums[j++]);\n                sum=max(sum,curr);\n            }\n            else{\n                curr-=nums[i];\n                s.erase(nums[i++]);\n            }\n        }\n        return sum;\n    }\n```\n
['C', 'Sliding Window', 'Ordered Set']