Problema
Mostra traduzioneWrite the decimal digits of n in reverse order and return the resulting number. Zeros that end up at the front disappear, so 1200 becomes 21.
Implement reverse_number(n).
Input
n: A positive integer.
Output
Return the reversed number.
Vincoli
1 ≤ n ≤ 10¹⁸. The reversed value always fits a signed 64-bit integer.
Esempi
Esempio 1
Input:
n = 352
Output atteso:
expected = 253
Input:
long long n = 352;
Output atteso:
long long expected = 253;
Input:
long n = 352;
Output atteso:
long expected = 253;
Spiegazione
The digits 3, 5, 2 reversed are 2, 5, 3.
Esempio 2
Input:
n = 1200
Output atteso:
expected = 21
Input:
long long n = 1200;
Output atteso:
long long expected = 21;
Input:
long n = 1200;
Output atteso:
long expected = 21;
Spiegazione
Reversed digits are 0021; leading zeros are dropped, giving 21.