Palindrome Number

Easy~10 min

Given an integer n, return true if it is a palindrome and false otherwise.

A palindrome number reads the same forwards and backwards. For example, 121 is a palindrome, but 123 is not.

Note: Negative numbers are NOT palindromes (the minus sign means they don't read the same backwards).

Examples

Example 1
Input: n = 121
Output: true
Explanation: 121 reads the same from left to right and right to left.
Example 2
Input: n = -121
Output: false
Explanation: Reading right to left gives 121-, which is not the same as -121.
Example 3
Input: n = 10
Output: false
Explanation: Reading right to left gives 01, which is not the same as 10.

Constraints

  • -10^9 <= n <= 10^9
Code
Ctrl+EnterRun|Ctrl+⇧+EnterSubmit
Output

Run your code to see results

Use Cmd+Enter to run