leetcode [Reverse Integer]
来源:互联网 发布:java sso单点登录框架 编辑:程序博客网 时间:2024/06/11 15:10
public class Solution { public int reverse(long a) {//题目中提到如果超过32-bit的返回0,想到的解决办法是用long来存,判断结果是否大于Integer.MAX_VALUE或小于Integer.MIN_VALUE long temp = 0;int res = 0;if(a < 0){a = Math.abs(a);while(a != 0){temp = temp * 10 + (a % 10);a = a / 10;}if(-temp < java.lang.Integer.MIN_VALUE){return 0;}else{res = -(int)temp;}}else{while(a != 0){temp = temp * 10 + (a % 10);a = a / 10;}if(temp > java.lang.Integer.MAX_VALUE){return 0;}else{res = (int)temp;}}return res; }}
0 0
- LeetCode:Reverse Integer
- LeetCode: Reverse Integer
- [Leetcode] Reverse Integer
- LeetCode : Reverse Integer
- [LeetCode] Reverse Integer
- Leetcode: Reverse Integer
- LeetCode 7 - Reverse Integer
- leetcode 104: Reverse Integer
- Leetcode : Reverse Integer
- 【leetcode】Reverse Integer
- [LeetCode]Reverse Integer
- LeetCode-Reverse Integer
- [leetcode] Reverse Integer
- LeetCode - Reverse Integer
- leetcode之Reverse Integer
- LeetCode | Reverse Integer
- LeetCode: Reverse Integer
- Leetcode: Reverse Integer
- Python中sorted函数的用法
- 国内可用免费语料库
- 每日一道算法题——3个数字相加等于0
- 巴尔扎克在小说中谈创作和灵感
- P2320 - 【长郡模拟赛】数据结构练习
- leetcode [Reverse Integer]
- 玩转Cglib代理
- 自定义异常(终止循环的节点)
- el表达式保留两位小数、使用jstl <fmt:formatNumber>标签保留两位小数
- 监听ViewPager滑动到最后一页时,再次拖动的方法监听
- git reset
- 学习SSM之MyBatis
- 调用REUSE_ALV_FIELDCATALOG_MERGE函数来获取FIELDCAT
- 10个你可能不知道的 Android Studio技巧