首页 > 其他 > 详细

Leetcode 34 Search for a Range

时间:2015-05-21 12:43:27      阅读:136      评论:0      收藏:0      [点我收藏+]


class Solution:
    # @param {integer[]} nums
    # @param {integer} target
    # @return {integer[]}
    def searchRange(self, nums, target):
        if target in nums:
            result = []
            start = nums.index(target)
            result.append(start)
            times = nums.count(target)
            result.append(start+times-1)
            return result
        else:
            return [-1, -1]


Leetcode 34 Search for a Range

原文:http://blog.csdn.net/andrew9tech/article/details/45889891

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!