C++Code easy to understand;


  • 0
    G
    bool isPerfectSquare(int num)
    {
        long long int i;
        if(num<0)
            return false;
        if(num==0)
            return true;
         for( i=1;i<=num;++i)
         {
             if(i*i>num)
                 return false;
             else if(i*i==num)
                 return true;
         }
    }

Log in to reply
 

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