Given an array of integers sorted in non-decreasing order and a target value, return the index of the first element that is greater than or equal to target. Assume such an element is guaranteed to exist.
Input
arr: array of integers sorted in non-decreasing order
target: value to compare against
Output
The index of the first element >= target.
Examples
Example 1
Inputarr = [1, 3, 3, 5, 8, 8, 10], target = 2
Output1
Explanation: The first element not smaller than 2 is 3, at index 1.
Example 2
Inputarr = [1, 3, 3, 5, 8, 8, 10], target = 5
Output3
Constraints
arr is sorted in non-decreasing order.
A satisfying element is guaranteed to exist.