2-line Java solution


  • 0
    C
        public int searchInsert(int[] nums, int target) {
            int i = Arrays.binarySearch(nums, target);
            return i < 0 ? ~i : i;
        }
    

Log in to reply
 

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