Search Insert Position
Easy
Searching
Array
Binary Search
Given sorted array and target, find the index where target would be inserted.
Constraints
1 ≤ nums.length ≤ 10^4
Examples
Example 1:
Input: 1 3 5 6
5
Output: 2
Example 2:
Input: 1 3 5 6
2
Output: 1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console