7. Reverse Integer-python
来源:互联网 发布:多益网络在哪里 编辑:程序博客网 时间:2024/06/05 06:07
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
Note:The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.
Code
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ isNegative = x < 0 if isNegative: x=-x rtn = 0; max32 = 2**31-1 # 32位符号整数的最大值 while x != 0: postBit = x%10 iterval = rtn*10 + postBit if iterval > max32: return 0 rtn = iterval x /= 10 return -rtn if isNegative else rtn
阅读全文
2 0
- 7. Reverse Integer-python
- 7. Reverse Integer Leetcode Python
- 7. Reverse Integer [easy] (Python)
- [leetcode:python]7.Reverse Integer
- Leetcode题解(Python): 7. Reverse Integer
- 【leetcode】7. Reverse Integer(Python & C++)
- leetcode-Reverse Integer-python
- Reverse Integer leetcode python
- Reverse Integer (python)
- 【Leetcode】【python】Reverse Integer
- 【LeetCode with Python】 Reverse Integer
- 【LeetCode】【Python题解】Reverse Integer
- leetcode Reverse Integer(python)
- leetcode-07-reverse integer-python
- Reverse Integer Leetcode Python Java
- 【LeetCode 7】Reverse Integer(Python)
- [LeetCode]7.Reverse Integer
- LeetCode 7. Reverse Integer
- JavaScript对象之String
- 一个比较好的Web框架概括(备用,只是框架这个词,没有技术内容)
- App测试技能树
- 数据库索引以及优化
- Servlet
- 7. Reverse Integer-python
- matlab在图片上写字后保存
- TCP报头标志位URG/PSH/SYN/ACK/FIN/RST
- 各个文件的作用域
- java基础试题4:笔试题2道
- linux 命令小記
- 自定义属性实现摇号排序
- 业务同学入门搜索,推荐的一些套路方案
- socket 套接字理解