A smart and very short solution


  • 0
    C
    public static int mySqrt(int x) {
        	try{
        		return (int)Math.sqrt(x);
        	}catch(Exception e){
        		return 0;
        	}
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.