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)
相关文章
- Java实现 LeetCode 999 车的可用捕获量(简单搜索)
- Java实现 LeetCode 438 找到字符串中所有字母异位词
- Java实现 LeetCode 405 数字转换为十六进制数
- Java实现 LeetCode 109 有序链表转换二叉搜索树
- Java实现 LeetCode 95 不同的二叉搜索树 II(二)
- Java实现 LeetCode 81 搜索旋转排序数组 II(二)
- 【LeetCode算法-26】Remove Duplicates from Sorted Array
- LeetCode(109):有序链表转换二叉搜索树
- LeetCode(33):搜索旋转排序数组
- 每日一道 LeetCode (24):将有序数组转换为二叉搜索树
- [LeetCode] Reverse Vowels of a String
- 【二分】LeetCode 33. 搜索旋转排序数组【中等】
- LeetCode(108):将有序数组转换为二叉搜索树
- ( “树” 之 BST) 109. 有序链表转换二叉搜索树 ——【Leetcode每日一题】
- 【LeetCode Python实现】13. 罗马数字转整数(简单)
- Leetcode 剑指 Offer 57. 和为s的两个数字(初版超时)
- [LeetCode] 33. 搜索旋转排序数组 ☆☆☆(二分查找)
- 【Leetcode刷题Python】96. 不同的二叉搜索树
- 【35】搜索插入位置【LeetCode】
- leetcode 搜索插入位置