JS Solution fails test but works fine in console ¯\_(ツ)_/¯


  • 0
    A

    For some reason this isn't working, failing input [1,2] with supposed output of []
    ran same input in the console and works fine ¯_(ツ)_/¯>! Spoiler

    var removeDuplicates = function(nums) {
        if (nums.length < 2) return nums
        let map = {}
        for (var i = nums.length - 1; i >= 0; i--) {
            if (map[nums[i]]) nums.splice(i, 1)
            else map[nums[i]] = true
        }
        return nums
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.