← 返回 bytedance 的题目列表Determine Whether an Integer Is a Palindrome
类型:online_judge
Given a 32-bit signed integer x, determine whether it is a palindrome.
A palindrome reads the same from left to right and right to left. For example, 121 is a palindrome, while -121 and 10 are not.
Describe both of the following approaches:
Converting the integer to a string.
Solving it without converting the integer to a string.
Input
One integer x.
Output
Print true if x is a palindrome; otherwise print false.
Constraints
-2^31 <= x <= 2^31 - 1
Example 1
Input: 121
Output: true
Example 2
Input: -121
Output: false
Example 3
Input: 10
Output: false
Example
Input
121
Output
true