Given a number N, the task is to check whether the number is Trimorphic number or not. A number is called Trimorphic number if and only if its cube ends in the same digits as the number itself. In other words, number appears at the end of its cube.
Input: N = 1
Explaination: 13 = 1. So the cube here is ending with
Input: N = 2
Explaination: 23 = 8. The cube is not ending with the
number at it's end.
Input: N = 24
Explaination: 243 = 13824. The cube is ending with 24.
You do not need to read input or print anything, Your task is to complete the function isTrimorphic() which takes N as input parameter and returns 1 if the number is trimorphic, otherwise, returns 0.
Expected Time Complexity: O(LogN) Expected Auxiliary Space: O(1)