My Two Line JAVA Solution


  • 0
    C
    class Solution {
        public int searchInsert(int[] nums, int target) {
            int index = Arrays.binarySearch(nums,target);
            return index < 0 ? -index - 1 : index;
        }
    }
    

Log in to reply
 

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