Maximum Erasure Value LeetCode solution in JavaScript

1
var maximumUniqueSubarray = function (nums) {
2
let nmap = new Int8Array(10001),
3
total = 0,
4
best = 0;
5
for (let left = 0, right = 0; right < nums.length; right++) {
6
nmap[nums[right]]++, (total += nums[right]);
7
while (nmap[nums[right]] > 1) nmap[nums[left]]--, (total -= nums[left++]);
8
best = Math.max(best, total);
9
}
10
return best;
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0