Fix this problem only with 2 lines of JavaScript


  • 0
    V
    var searchInsert = function(nums, target) {
        for(let i = 0; i < nums.length; i++) if(target <= nums[i]) return i
        return nums.length
    };
    

Log in to reply
 

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