Sum of Square Number(Java Solution) Runtime-2 ms
75
Aug 25, 2021
class Solution {
    public boolean judgeSquareSum(int c) {
        int left=0;
        int right=(int)Math.sqrt(c);
        while(left<=right){
int total=left*left+right*right;
        if(total==c){
            return true;
        }
        else if(total>c){
            right--;
        }
        else{
            left++;
        }
        }
        return false;
    }
}
Comments (0)