A simple C solution[Accepted]


  • 0
    B
    bool judgeSquareSum(int c) {
        if(sqrt(c)==(int)sqrt(c)){return true;}
        int temp=0;
        for(int i=1;i<=c/i;i++){
            temp=c-i*i;
            if(sqrt(temp)==(int)sqrt(temp)){return true;}
        }
        return false;
    }
    

Log in to reply
 

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