Skip to content

Commit aece3b9

Browse files
committed
committed from zkp
1 parent 9739cc2 commit aece3b9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

LeetCode/firstBadVersion.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# The isBadVersion API is already defined for you.
2+
# @param version, an integer
3+
# @return a bool
4+
# def isBadVersion(version):
5+
6+
class Solution(object):
7+
def firstBadVersion(self, n):
8+
"""
9+
:type n: int
10+
:rtype: int
11+
"""
12+
l = 1
13+
r = n
14+
while l < r:
15+
mid = (l+r)//2
16+
# print(isBadVersion(mid))
17+
if not isBadVersion(mid):
18+
l = mid + 1
19+
else:
20+
r = mid
21+
return l
22+

0 commit comments

Comments
 (0)