Reverse Number Digits
Sometimes you need to split a number into digits and build it back in a different order, which is good practice for working with numbers and strings. Write a function reverse_integer that reverses the digits of the non-negative integer n. If the reversed number starts with zeros, they disappear automatically: for example, 1200 becomes 21. For 0, return 0.
Примеры
Ввод
123Вывод
321Ввод
1200Вывод
21Ввод
0Вывод
0Нужно реализовать
def reverse_integer(n: int) -> int:
Теги
math
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
123Expected
3212
Input
1200Expected
213
Input
0Expected
04
Input
5Expected
55
Input
100000Expected
16
Input
987654321Expected
123456789Focus radio
Paused · SomaFM · Fluid