Javascript | Sliding Window Solution w/ Explanation | 100% / 100%
In order to solve this in O(n) time, we can use a sliding window to evaluate all usable subarrays. For that, we\'ll need to use some data type to keep track of 
In order to solve this in **O(n)** time, we can use a sliding window to evaluate all usable subarrays. For that, we\'ll need to use some data type to keep track of the numbers in our sliding window. \n\nNormally, I would use a **Map** to keep track of this information, but because we\'re using numbers as keys and because the constraint upon the numbers is so small at **1 <= N[i] <= 10e4**, it is more efficient to use an array. Also, since our array will only need to keep track of three possibilities (**0**, **1**, or **2**), we can use the more lightweight **Int8Array**. As an **Int8Array** is typed, when it is instantiated, it is automatically filled with **0**s.\n\nAs we iterate through **N**, we\'ll also need to keep track of the **sum** of the window and the **max** sum we\'ve seen. The main **for** loop will increase the right end index (**r**) of the window and at each number, we\'ll increase the counter of the current number in our array (**a**) and add its value to our **sum**.\n\nThen, if that number appears more than once in the window (**a[N[r]] > 1**), we\'ll drop numbers out of the sliding window by decreasing the counter for that number in **a**, subtracting its value from our **sum**, and increasing the left index (**l**) until we no longer have the duplicate.\n\nAfter that, we just check to see if we need to update **max**, and when we reach the end return it.\n```\n\nvar maximumUniqueSubarray = function(N) {\n    let a = new Int8Array(10001), sum = max = 0, len = N.length\n    for (let l = 0, r = 0; r < len; r++) {\n        a[N[r]]++, sum += N[r]\n        while (a[N[r]] > 1) a[N[l]]--, sum -= N[l++]\n        max = sum > max ? sum : max\n    }\n    return max\n};\n```
['Sliding Window', 'JavaScript']