Problem :

https://leetcode.com/problems/reverse-integer/description/


My Solution :

class Solution:
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
sign = 1
if x < 0:
sign = -1
x = -x

result = 0
while x:
result = 10*result + x % 10
x //= 10
if 2**31 < result:
return 0
return sign * result


Comment :

문자열로 변환하지 않고 풀어야 의미가 있는 문제.