头像

刷完剑指offer了时间复杂度都没改

UCSD


访客:30601

离线:1个月前



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)

//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)

//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)

//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)

//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~


活动打卡代码 AcWing 49. Group Anagrams

//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)

//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~


活动打卡代码 AcWing 38. Count and Say

//这里填你的代码^^class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)


//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~


活动打卡代码 AcWing 101. Symmetric Tree

//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



//这里填你的代码^^
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        if target in nums:
            return nums.index(target)
        else:
            if target < nums[0]:
                return 0
            for i in range(len(nums)-1):
                if nums[i] < target and target < nums[i + 1]:
                    return i + 1
            if target > nums[-1]:
                return len(nums)
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~