Search Insert Position
nums is sorted in increasing order with no repeats. If target is in the list, return its index. Otherwise return the index where it would have to be inserted to keep the list sorted.
Example 1
nums [1,3,5,6]
target 5
returns 2
5 is at index 2.
Example 2
nums [1,3,5,6]
target 2
returns 1
2 would go between 1 and 3, at index 1.
Constraints
0 <= len(nums) <= 40-100 <= nums[i], target <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.