摘要: Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.https://leetcode.com/problems/sqrtx/对于数学早就还给老师的我,开方真是跪了。查了一下是牛顿迭代法(什么鬼。先随便猜一个数,... 阅读全文
posted @ 2015-06-25 22:57 `Liok 阅读(463) 评论(0) 推荐(0) 编辑
摘要: Pow(x, n)Implement pow(x,n).https://leetcode.com/problems/powx-n/注意x和n都可能是负数。递归,二分折半,比如求3的4次方,可以拆成3的2次方相乘;3的5次就是3^2相乘再乘2。 1 /** 2 * @param {number} x... 阅读全文
posted @ 2015-06-25 22:52 `Liok 阅读(774) 评论(0) 推荐(0) 编辑