My five line Java solution


  • 0
    B
     public int searchInsert(int[] nums, int target) {
            int i=0;
            while(nums[i]<target){
                    i++;
                if (i == nums.length) break;}
                return i; }
    }
    

Log in to reply
 

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