7-Reverse-Integer
Sat 17 May 2025
https://leetcode.com/problems/reverse-integer
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def reverse(self, x: int) -> int:
ans = 0
sign = -1 if x < 0 else 1
x *= sign
while x:
ans = ans * 10 + x % 10
x //= 10
return 0 if ans < -2**31 or ans > 2**31 - 1 else sign * ans
new Solution().reverse()
Score: 5
Category: leetcode