704. 二分查找
Ideas这题想考察二分查找的来着。
对不起,真的对不起,作为Python爱好者,实在没忍住,就一行代码解决了。
Code Pythonfrom typing import List class Solution: def search(self, nums: List[int], target: int) -> int: return nums.index(target) if target in nums else -1
704. 二分查找
Ideas这题想考察二分查找的来着。
对不起,真的对不起,作为Python爱好者,实在没忍住,就一行代码解决了。
Code Pythonfrom typing import List class Solution: def search(self, nums: List[int], target: int) -> int: return nums.index(target) if target in nums else -1
微信扫码登录