Sqrt Archives - Coddicted

Sqrt

Title: Sqrt(x) Source: leetcode.com Implement int sqrt(int x). Compute and return the square root of x. Java solution Java /* https://leetcode.com/problems/sqrtx/ */ class Sqrt { public static void main(String args[]) throws Exception { Sqrt solution = new Sqrt(); System.out.println(solution.mySqrt(2147395599)); } public int mySqrt(int x) throws Exception { if(x==0 || x==1) return x; long lo = ...