LeetCode 278. First Bad Version (Python)最优解--Apolo_Shane
2018-01-26 00:49
603 查看
#典型的二分查找。
#注意边界问题。
class Solution(object): def firstBadVersion(self, n): l=1 r=n while True: mid=(l+r)//2# if isBadVersion(mid): r=mid-1 else: l=mid+1 if r<l: break return l
相关文章推荐
- LeetCode 120. Triangle (Python)最优解--Apolo_Shane
- LeetCode 63. Unique Paths II (Python)最优解--Apolo_Shane
- LeetCode 62. Unique Paths (Python)最优解--Apolo_Shane
- LeetCode 746. Min Cost Climbing Stairs (Python)最优解--Apolo_Shane
- LeetCode 96. Unique Binary Search Trees (Python)最优解--Apolo_Shane
- LeetCode 64. Minimum Path Sum (Python)最优解--Apolo_Shane
- [LeetCode]Construct Binary Tree from Preorder and Inorder Traversal@python
- LeetCode 73 Set Matrix Zeroes(Python详解及实现)
- 【python】【leetcode】【算法题目412—Fizz Buzz】
- 168. Excel Sheet Column Title Leetcode Python
- [Leetcode,python] Majority Element 众数
- python--leetcode 419. Battleships in a Board
- [LeetCode] Maximum Depth Of Binary Tree Python 题解
- 127. Word Ladder Leetcode Python
- 【LeetCode】413. Arithmetic Slices 解题报告(Python)
- 118. Pascal's Triangle Leetcode Python
- LeetCode 27. Remove Element——python(easy)
- LeetCode 8 String to Integer (atoi) (C,C++,Java,Python)
- leetcode100题 题解 翻译 C语言版 Python版
- 【LEETCODE】148- Sort List [Python]