鱼C论坛

 找回密码
 立即注册
查看: 3748|回复: 15

[技术交流] 1.Reverse Integer

[复制链接]
发表于 2020-3-12 12:07:50 | 显示全部楼层
我也来
  1. class Solution:
  2.     def reverse(self, x: int) -> int:
  3.         f=False
  4.         if x<0:
  5.             x=-x
  6.             f=True
  7.             
  8.         res=0
  9.         power=0
  10.         while x:
  11.             res=res*10+x%10
  12.             x//=10
  13.         
  14.         if -2147483648<res<2147483647:
  15.             return -res if f else res
  16.         else:
  17.             return 0
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-4-1 15:47

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表