Skip to content

Commit e2fd78e

Browse files
committed
Create: 0278-first-bad-version.py
1 parent e147dcd commit e2fd78e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: python/0278-first-bad-version.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def firstBadVersion(self, n: int) -> int:
3+
l, r = 1, n
4+
while l < r:
5+
v = (l + r) // 2
6+
if isBadVersion(v):
7+
r = v
8+
else:
9+
l = v + 1
10+
return l

0 commit comments

Comments
 (0)