0
点赞
收藏
分享

微信扫一扫

双指针之平方数之和

苦茶如歌 2022-01-31 阅读 39

每日一题ing,今天是个medium题633. Sum of Square Numbers

class Solution {
public:
    bool judgeSquareSum(int c) {
        long long i=0,j=sqrt(c);
        while(i<=j){
            long long temp=i*i+j*j;
            if(temp==c){
                return true;
            }
            if(temp>c){
                j--;
            }
            else{
                i++;
            }
        }
        return false;
    }
};
举报

相关推荐

0 条评论