Find First and Last Position of Element in Sorted Array
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1].
(在时间复杂度为O(log n)的前提下在有序数组中检索target的第一次及最后一次)
Example:

1. 二分查找
1 | class Solution: |