Please enter your email address or userHandle.
Given an integer N, check if it is possible to represent it as a function(a, b) such that : a2 + b2 = N where "a" and "b" are whole numbers. Print 1 if it's possible, else Print 0.
N = 1
12 + 02 = 1. So, the Output is 1
N = 2
12 + 12 = 2. So, the Output is 1
N = 7
We don't have a or b, which when summed
after squaring gives 7. So, Output is 0.
You don't need to read input or print anything. Your task is to complete the function checkSquares() which takes an Integer N as input and returns the answer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
1 <= N <= 106
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.