My easy solution using Math class

  • -6
    public class Solution {
        public boolean isPerfectSquare(int num) {
            double rst = Math.sqrt(num);
            if(rst != Math.rint(rst)) return false;
            return true;

  • 1

    Part of the problem statement was to not use Math.sqrt.

Log in to reply

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