I know I did something wrong, I'm just trying to figure out why my hashmap solution isn't giving me the right answer for this leetcode problem.
The problem: https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/
My solution:
var removeDuplicates = function(nums) {
let map = new Map();
for(var i = 0; i < nums.length; i++){
if(nums[i] in map){
nums.splice(i, 1)
}
else{
map[nums[i]] = i;
}
}
};
UPDATE: This is NOT a duplicate. The new information that I learned is that using splice WILL update the index. That information is missing from the question referred to as the 'duplicate'