You are given an array nums sorted in non-decreasing order, and a number target. Find the first index and the last index where target appears in the array, and return them as [first, last].
If target is not in the array, return [-1, -1].
Your solution must run in O(log n) time.
Examples
Example 1:
Input: nums = [2,4,4,4,9], target = 4
Output: [1,3]
Explanation: The number 4 sits at indexes 1, 2 and 3. The first is 1 and the last is 3.
Example 2:
Input: nums = [2,4,4,4,9], target = 5
Output: [-1,-1]
Explanation: 5 is not in the array.
Example 3:
Input: nums = [], target = 3
Output: [-1,-1]
Explanation: The array is empty.