// The API isBadVersion is defined for you. // bool isBadVersion(int version);classSolution{ public:intfirstBadVersion(int n){int l&#61;1,r&#61;n;while(l<r){int mid&#61;l&#43;(r-l)/2;if(isBadVersion(mid)&#61;&#61;false) l&#61;mid&#43;1;else r&#61;mid;}return l;} };