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.
範例 1:
輸入: nums = [5,7,7,8,8,10], target = 8 輸出: [3,4]
範例 2:
輸入: nums = [5,7,7,8,8,10], target = 6 輸出: [-1,-1]
限制條件:
0 <= nums.length <= 10^5nums is sorted in ascending order.