LeetCode Algorithm 704. 二分查找
生活随笔
收集整理的這篇文章主要介紹了
LeetCode Algorithm 704. 二分查找
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
704. 二分查找
Ideas
這題想考察二分查找的來著。
對不起,真的對不起,作為Python愛好者,實在沒忍住,就一行代碼解決了。
Code
Python
from typing import Listclass Solution:def search(self, nums: List[int], target: int) -> int:return nums.index(target) if target in nums else -1總結
以上是生活随笔為你收集整理的LeetCode Algorithm 704. 二分查找的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2019年第十届蓝桥杯 - 省赛 - C
- 下一篇: LeetCode Algorithm 1