C++ || Maximum Erasure Value || O(n)
class Solution {\npublic:\n    int maximumUniqueSubarray(vector& nums) {\n  \n        // Sliding Window Approach\n        // Untill duplicate elements we keep o
class Solution {\npublic:\n    int maximumUniqueSubarray(vector<int>& nums) {\n  \n        // Sliding Window Approach\n        // Untill duplicate elements we keep on adding and increase our window size\n        // hash set -> to keep check for unique elements\n        // ans -> storing the maximum sum till now\n        // currSum -> storing current sum of the window\n        \n        unordered_set<int> hashset;\n        \n        int ans = 0;\n        int currSum = 0;\n        \n        int i = 0;\n        int j = 0;\n        while(j < nums.size()){\n            \n            while(hashset.find(nums[j]) != hashset.end()){  // if element present -> remove it\n                hashset.erase(nums[i]);\n                currSum -= nums[i];\n                i++;\n            }\n            \n            hashset.insert(nums[j]);   // if element not present -> add it\n            currSum += nums[j];\n            j++;\n            \n            ans = max(ans, currSum);       \n        }\n        \n        return ans;\n    }\n};
['Array', 'Two Pointers', 'C', 'Sliding Window']