摘要:
快速幂。处理当指数为负数时的情景,还要注意int32的数据范围。 class Solution { public double myPow(double x, int n) { if(x==0) return 0; double res=1; long b=n; if(n<0) { x=1/x; b 阅读全文
摘要:
这道题绝了,虽然是简单题,但是可以暴露不少问题。 // you need to treat n as an unsigned value public int hammingWeight(int n) { int cnt =0; int tmp; while(n!=0){//!!不可以写成n>0,因 阅读全文