1 line Maths Solution (3 ms)


  • 0
    E

    This is a solution using Math functions.

    class Solution {
        public int mySqrt(int x) {
            return (int)(Math.round(Math.pow(Math.E,Math.log(x)/2)*100000d)/100000d);
        }
    }
    

Log in to reply
 

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