class Solution {
public:
int firstBadVersion(int n) {
int from,to,mid;
from=1;to=n;
while(from!=to)
{
mid=((long long)from+to)/2;
if(isBadVersion(mid)==true)
{
to=mid;
}
else
{
from=mid+1;
}
}
return from;
}
};
My 0ms c++ solution with O(logn) time and O(1) space

There is a hidden trap in this problem , the max positive value the type 'int' can store is 2147483647(2 ^ 32  1) , if there are 2147483647 versions than (1 + 2147483647) will overflow and the value wrapped to negative , so you must explicitly convert the value to the long long type to avoid the bad things happen.May these be helpful. :D