Given a sorted array of integers, 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].
For example,
Given [5, 7, 7, 8, 8, 10] and target value 8,
return [3, 4].
{优快云:CODE:633034}

本文介绍如何在一个已排序的整数数组中找到给定目标值的起始和结束索引,算法的时间复杂度须为 O(log n)。若目标值未出现在数组中,则返回 [-1, -1]。通过实例演示,如数组 [5,7,7,8,8,10] 和目标值 8,输出为 [3,4]。
445

被折叠的 条评论
为什么被折叠?



