1-liner C++


  • 0

    As many similar solutions have been posted ...

        bool isPerfectSquare(int n) {
            for (int i = 0; ; n -= 2*i++ +1) if (n <= 0) return !n; 
        }
    

Log in to reply
 

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