码迷,mamicode.com
首页 > 其他好文 > 详细

35. Search Insert Position

时间:2017-12-17 17:00:50      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:ret   highlight   class   osi   tar   ==   object   sea   pre   

class Solution(object):
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            for i in range(len(nums)):
                if target==nums[i]:
                    return i
        else:
            for i in range(len(nums)):
                if target<nums[i]:
                    return i
            return len(nums)

  

35. Search Insert Position

标签:ret   highlight   class   osi   tar   ==   object   sea   pre   

原文地址:http://www.cnblogs.com/xlqtlhx/p/8052382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!