zl程序教程

您现在的位置是:首页 >  其他

当前栏目

leetcode 搜索旋转排序数组

2023-09-14 09:15:50 时间
class Solution(object):
    def search(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        #nn=nums[k:]+nums[:k]
        nn=nums
        if target in nn:
            return nn.index(target)
        else:
            return -1

a=[1,2,3,4,5,6]
c=Solution()
import time
t1=time.time()

#计算几个数之和,下面就填几
c1=c.search( a,5)
print(time.time()-t1)

print(c1)