My 5 lines code(Java)


  • 0
    Y

    public int searchInsert(int[] nums, int val){
    int i = 0;
    for( i = 0; i < nums.length; i ++){
    if(nums[i] >= val) break;
    }
    return i;
    }


Log in to reply
 

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