Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int firstBadVersion(int n) {
- int l=1, h = n;
- //Binary search to find first true for the condition isBadVersion(m)==true
- while(l<h){
- int m = l+ (h-l)/2;
- if(isBadVersion(m)==true){
- h = m;
- }
- else{
- l = m+1;
- }
- }
- return l;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement