top of page

Looking to master object-oriented and system design for tech interviews or career growth?

• Improve your system design and machine coding skills.

• Study with our helpful resources.

**We're in beta mode and would love to hear your feedback.

Search

Palindrome Integer InterviewBit Solution

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)

Code in C++

Tags: