My 5 line java solution (runs in 5ms)


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

Log in to reply
 

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