Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution { public: bool isPerfectSquare(int num) { if(num <= 0)return false; int sq = sqrt(num); return (sq*sq == num); } };

Obviously, with sqrt, the question looks trivial. You should not use it.

sqrt

"Note: Do not use any built-in library function such as sqrt."

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