Wednesday, January 22, 2014

Sqrt(x) (Java)

Leetcode

Implement int sqrt(int x).
Compute and return the square root of x.


Solution: remember that the sqrt of an number must less than  its half, than we we can apply binary search to find our target. pleas don't forget the overflow risk