Why not use sqrt?


  • 0
    G
    public boolean isPerfectSquare(int num) {
        double sqrt = Math.sqrt(num);
        return sqrt - Math.floor(sqrt) > 0 ? false : true;
      }
    

  • 0

    @xiyunyue The problem stated that "Do not use any built-in library function such as sqrt."


Log in to reply
 

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