LeetCode Problem

633. Sum of Square Numbers Link to LeetCode Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: c = 5 Output: true Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: c = 3 Output: false class Solution { public boolean judgeSquareSum(int c) { int cx = (int)Math.sqrt(c); long i=0,j=cx; while (i <= j) { long temp = i*i + j*j; if (temp==c) return true; else if(temp< c)i++; else j--; } return false; } }