20. Find First and Last Position of Element in Sorted Array
Given an integer array nums sorted in ascending order and a target, return the starting and ending position of target, or [-1, -1] if it is absent.
Example 1:
Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4]
Example 2:
Input: nums = [5,7,7,8,8,10], target = 6 Output: [-1,-1]
Constraints:
0 <= nums.length <= 10^5nums is sorted in ascending order.