Given a number N, write a program to check whether given number is Adam Number or not.
Adam number is a number when reversed, the square of the number and the square of the reversed number should be numbers which are reverse of each other.
Input: N = 12 Output: YES Explanation: 122 = 144 and 212 = 441. 144 reversed gives 441, So, it's an Adam Number.
Input: N = 12 Output: YES Explanation: 142 = 196. 196 reversed gives 691, which isn't equal to 412 So, it's not an Adam Number.
You don't need to read input or print anything. Your task is to complete the function checkAdamOrNot() which takes an Integer N as input and returns the answer as "YES" if it is a Ada, number. Otherwise, returns "NO".
Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(1)
1 <= N <= 104
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes