Incorrect test case results


  • -1
    R

    My code works correctly in my local and console of Chrome same test input
    However on leetcode it gives incorrect results.

    var removeDuplicates = function(nums) {
    var i = 0;
    var j = 1;

    if (nums.length === 0) {
        return 0;
    }
    
    if (nums.length === 1) {
        return 1;
    }
    
    while (i < nums.length - 1 && j < nums.length) {
    
        if (nums[i] == nums[j]) {
            nums.splice(j, 1);
    
        } else {
            i++;
            j++;
        }
    }
    
    return nums;
    

    };


Log in to reply
 

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