743. Recursive Palindrome Number Check

EasyRecursionRecursion

Given an integer n, determine whether it reads the same forwards and backwards as a base-10 number (a palindrome). Negative numbers are NOT palindromes (because of the leading minus sign). For example, 121 and 1221 are palindromes, while 123 and -121 are not. Implement the check recursively (e.g., compare first and last digits, then recurse on the middle).

Input: A single integer n.

Output: Return a boolean: true or false (lowercase).

Examples

Example 1
Input: 121
Output: true
Explanation: 121 reversed is 121.
Example 2
Input: -121
Output: false
Explanation: Reversed it would be 121-, which is not the same.
Example 3
Input: 10
Output: false
Explanation: Reversed is 01 = 1, not 10.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →