Reverse the Digits
Sometimes you need to work with a number digit by digit while still respecting its sign and integer limits. Given a 32-bit signed integer x, return the number with its digits reversed. If the reversed value is outside the range from -2**31 to 2**31 - 1, return 0.
Примеры
Ввод
123Вывод
321Ввод
-123Вывод
-321Ввод
120Вывод
21Нужно реализовать
def reverse_integer(x: int) -> int:
Теги
math
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
123Expected
3212
Input
-123Expected
-3213
Input
120Expected
214
Input
0Expected
05
Input
1534236469Expected
06
Input
100Expected
1Focus radio
Paused · SomaFM · Fluid