All challenges
Easy 0 solved 0% acceptance

Palindrome Number

Check whether a number reads the same backwards.

Problem

Decide whether the decimal digits of n read the same forwards and backwards. Negative numbers are never palindromes because of the minus sign.

Implement is_palindrome_number(n).

Input

n: The number to check.

Output

Return true for a palindromic number, otherwise false.

Constraints

-10¹⁸ ≤ n ≤ 10¹⁸

Examples

Example 1
Input:
n = 12321

Expected output:
expected = True
Input:
long long n = 12321;

Expected output:
bool expected = true;
Input:
long n = 12321;

Expected output:
bool expected = true;

Explanation

12321 reversed is 12321.

Example 2
Input:
n = -121

Expected output:
expected = False
Input:
long long n = -121;

Expected output:
bool expected = false;
Input:
long n = -121;

Expected output:
bool expected = false;

Explanation

The minus sign makes "-121" differ from "121-".

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.