Last Position of a Target in a Sorted Array
Problem statement
nums is sorted in nondecreasing order. Return the zero-based index of the final occurrence of target, or -1 if target is absent.
Function
lastPosition(nums: int[], target: int) → intExamples
Example 1
nums = [1,2,2,2,3]target = 2return = 3The final 2 occurs at index 3.
Constraints
0 <= nums.length <= 10^5.