Problema
Mostra traduzioneDecide 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.
Vincoli
-10¹⁸ ≤ n ≤ 10¹⁸
Esempi
Esempio 1
Input:
n = 12321
Output atteso:
expected = True
Input:
long long n = 12321;
Output atteso:
bool expected = true;
Input:
long n = 12321;
Output atteso:
bool expected = true;
Spiegazione
12321 reversed is 12321.
Esempio 2
Input:
n = -121
Output atteso:
expected = False
Input:
long long n = -121;
Output atteso:
bool expected = false;
Input:
long n = -121;
Output atteso:
bool expected = false;
Spiegazione
The minus sign makes "-121" differ from "121-".
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.