您的位置:首页 > 其它

leetcode 34[medium]---Search for a Range

2017-12-18 23:37 429 查看
难度:mediumGiven an array of integers 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]
.For example,
Given 
[5, 7, 7, 8, 8, 10]
 and target value 8,
return 
[3, 4]
.思路:有点搞不懂leetcode的难度分类,明明有些easy级别的题都要难出此题很多。当然也许是自己的python知识结构还太不完善的原因。          给定一个已经sort过的array,找出给定target所在的范围,如果array中没有与target值相同的element则return[-1,-1]. 如果array中只有一个target的element,return[i,i].  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode