Two Pointers with HashSet Solution (with step by step explanationTwo)
Intuition\nWe will use two pointer approach with HashSet to solve this problem\n# Approach\nWe declare HashSet to check for unique in our window, then we iterat
# Intuition\nWe will use two pointer approach with HashSet to solve this problem\n# Approach\nWe declare HashSet to check for unique in our window, then we iterate over nums array, and check if num at right pointer unique to our sub array that we collect in window set, if we found that it\'s not unique then we delete nums from window coming from left pointer, until our window agailn be unique, then we place num at right pointer into window and repeat, on each iteration we support sum of our window by incrementing if num is unique and decrement if not.\n# Complexity\n- Time complexity:\nO(n) -> we iterate with left and right pointers only once\n- Space complexity:\nO(n) -> we use HashSet to store our window\n# Code\n```\nfunction maximumUniqueSubarray(nums: number[]): number {\n    // declare window HashSet\n    const window = new Set<number>();\n    // declare left pointer\n    let left = 0;\n    // declare max variable that will store result\n    let max = 0;\n    // declare count variable that will store current window sum\n    let count = 0;\n    // iterate over nums array:\n    for(let right = 0; right < nums.length; right++) {\n        // if number at right pointer are not unique to our window:\n        while(window.has(nums[right])) {\n            // we delete number on left pointer from set\n            window.delete(nums[left])\n            // we subtract num from window sum\n            count -= nums[left]\n            // we increment left pointer\n            left++;\n        }\n        // if number unique we add it to our window set\n        window.add(nums[right])\n        // and add number to window sum\n        count += nums[right];\n        // check current sum and max and find bigger\n        max = Math.max(max, count)\n    }\n    // return result\n    return max\n};\n```
['Hash Table', 'Two Pointers', 'TypeScript']