Easy C++ Solution using Two Pointers
The idea here is to keep track  of all the elements already visited using a set and deploy two pointers (i&j) to adjust our current window.\nThe flow is as foll
The idea here is to keep track  of all the elements already visited using a set and deploy two pointers (i&j) to adjust our current window.\nThe flow is as follows:\n* If the current element is not already present in the set we simply add it to our curr_sum and extend the window...\n* If the element is already present in the set, we start removing elements from start of our window until we delete the required element...\n* We keep track of maximum result using another variable...\n\n**Example 1: Lets take this to be our current i and j positions...**\n![image](https://assets.leetcode.com/users/images/89277aea-2b32-4ace-8668-8b0aee1386f5_1655004659.963234.png)\nNow since 5 is not already present in our set, we simply add it to curr_sum variable and increment the j value...\n\n\n**Example 2:**\n![image](https://assets.leetcode.com/users/images/6f8d30a8-9193-4751-8c7c-4e0b471a371c_1655004974.6213708.png)\nNow here we are adding 7, which is already present in our set, so we start remove elements of ith index from set and also subtract them from our curr_sum value until we remove the value 7...\n\n**If you found the solution, pls upvote this thread.**\n\n```\nclass Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n        int curr_sum=0, res=0;\n\t\t\n\t\t//set to store the elements\n        unordered_set<int> st;\n        \n        int i=0,j=0;\n        while(j<nums.size()) {\n            while(st.count(nums[j])>0) {\n\t\t\t\t//Removing the ith element untill we reach the repeating element\n                st.erase(nums[i]);\n                curr_sum-=nums[i];\n                i++;\n            }\n\t\t\t//Add the current element to set and curr_sum value\n            curr_sum+=nums[j];\n            st.insert(nums[j++]);\n\t\t\t\n\t\t\t//res variable to keep track of largest curr_sum encountered till now...\n            res = max(res, curr_sum);\n        }\n        \n        return res;\n    }\n};\n```
['Two Pointers', 'C', 'C++']