Problems / Palindrome Number
Easy

Palindrome Number

Easy 0 submissions 10 coins +50 XP
Math
Problem Description
## Problem Given an integer `x`, return `True` if `x` is a **palindrome**, and `False` otherwise. An integer is a palindrome when it reads the same forward and backward. **Do not** convert the integer to a string to solve this problem. ## Examples **Example 1:** ``` Input: x = 121 Output: True Explanation: 121 reads as 121 from left to right and from right to left. ``` **Example 2:** ``` Input: x = -121 Output: False Explanation: From left to right, it reads -121. From right to left, it reads 121-. Therefore it is not a palindrome. ``` **Example 3:** ``` Input: x = 10 Output: False Explanation: Reads 01 from right to left. Therefore it is not a palindrome. ``` ## Hints - Negative numbers are never palindromes. - Reverse only the second half of the number and compare with the first half. - A number ending in 0 (except 0 itself) cannot be a palindrome.
Constraints
- `-2^31 <= x <= 2^31 - 1`

Need help?

Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.

Video Call Whiteboard Live Coding Screen Share