Advertisement
arvind_iyer_2001

Untitled

Jun 22nd, 2021 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. def firstBadVersion(self, n):
  2.     l = 0
  3.     r = n
  4.     while l<r:
  5.         m = (l + r)//2
  6.         print(l,m,r)
  7.         if(isBadVersion(m)):
  8.             r = m
  9.             if(r == l + 1):
  10.                 return m
  11.         else:
  12.             l = m
  13.             if(r == l + 1):
  14.                 return l + 1
  15.     return l
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement