Palindrome Integer InterviewBit Solution
Problem: Palindrome Integer
Problem Description:
Determine whether an integer is a palindrome. Do this without extra space.
A palindrome integer is an integer x for which reverse(x) = x where reverse(x) is x with its digit reversed. Negative numbers are not palindromic.
Example :
Input : 12121
Output : True
Input : 123
Output : False
Approach
The approach is straight forward, we just convert the given number into a string, and then can check whether the string is palindrome or not.
Another method could be that we can store this number to another number and then reverse one of them.
Time & Space Complexity:
Time Complexity: O(N), N is the number of digits in given number
Space Complexity: O(1)
Solution:
Code in C++
Comments