编程技术 【leetcode】sqrt(int x) Question:Implementintsqrt(intx).Computeandreturnthesquarerootofx.Anwser1:二分法classSolution{public:intsqrt(intx){if(x<0)return-1;//assert(x>=0);longlongx2=(longlong)x;longlongleft=0;longlongright=x2;longlongmid=0;while(left<=right){ 系统 2019-08-29 23:44:26 2535