nums is sorted in non-decreasing order and may contain repeated values. Return [first, last]: the first and the last index where target appears. If it does not appear, return [-1, -1].
Example 1
Input:
first_and_last([5, 7, 7, 8, 8, 10], 8)
Output:
[3, 4]
Example 2
Input:
first_and_last([5, 7, 7, 8, 8, 10], 6)
Output:
[-1, -1]
0 <= len(nums) <= 2 * 10**5nums is sorted in non-decreasing order.-10**9 <= nums[i], target <= 10**9in, .index, .count, min or sorted on the whole list, fails them.No results yet
Run your code to check it against the examples, or submit to run every test.