JavaScript O(n) time, O(1) space solution


  • 0
    C
    var missingNumber = function(nums) {
        var result = 0;
        nums.forEach(function(e,i,a) {
            result = result + i - e;
        })
        return result + nums.length;
    };

Log in to reply
 

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