Insert Position
ARRAY
Problem
Given a sorted array of distinct integers nums
and a target value target
, return the index if the target
is found. If not, return the index where it would be if it were inserted in order.
Examples
searchInsert([1,2,3,4,5], 0) // returns 0 searchInsert([1,3,5,7,9], 8) // returns 4 searchInsert([2,4,6,8,10], 1) // returns 0
Loading...