Search Insert Position (Lower Bound)

Easy · Binary Search · about 10 minutes

Asked at Amazon, Google, Apple.

nums is sorted ascending with no repeats. If target is in it, return its position; if not, return the position at which inserting target would keep the array sorted. Stay within O(log n).

Related guides