We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 55723b7 commit ee8128eCopy full SHA for ee8128e
May-LeetCoding-Challenge/First-Bad-Version/First-Bad-Version.py
@@ -0,0 +1,19 @@
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:
7
+ def firstBadVersion(self, n):
8
+ """
9
+ :type n: int
10
+ :rtype: int
11
12
+ left, right = 1, n
13
+ while left < right:
14
+ mid = left + (right - left) // 2
15
+ if isBadVersion(mid):
16
+ right = mid
17
+ else:
18
+ left = mid + 1
19
+ return left
0 commit comments