First and Last Position in a Sorted Array
Medium · Binary Search · about 15 minutes
Asked at Meta, Amazon, LinkedIn, Uber.
Given a sorted integer array nums (with duplicates) and a target, return [first, last] — the first and last index of target — or [-1, -1] if it is not present. Run in O(log n).