当前位置:网站首页>[leetcode] 92 integer inversion
[leetcode] 92 integer inversion
2020-11-09 23:48:00 【JaneRoad】
subject :
Their thinking :
Pop and push numbers & Check before spillage
https://leetcode-cn.com/problems/reverse-integer/solution/zheng-shu-fan-zhuan-by-leetcode/
Code :
package com.janeroad;
/**
* Created on 2020/11/9.
*
* [@author](https://my.oschina.net/arthor) LJN
*/
public class LC142 {
public static void main(String[] args) {
System.out.println(reverse(1999));
}
public static int reverse(int x) {
int rev = 0;
while (x != 0) {
int pop = x % 10;
x /= 10;
if (rev > Integer.MAX_VALUE/10 || (rev == Integer.MAX_VALUE / 10 && pop > 7)) return 0;
if (rev < Integer.MIN_VALUE/10 || (rev == Integer.MIN_VALUE / 10 && pop < -8)) return 0;
rev = rev * 10 + pop;
}
return rev;
}
}
版权声明
本文为[JaneRoad]所创,转载请带上原文链接,感谢
边栏推荐
- IP地址SSL证书
- ERP的权限管理的操作与设计--开源软件诞生24
- Gets the property value of a column in the list collection object
- jt-京淘项目
- DB engines database ranking in November: PostgreSQL holds the top spot in the same period
- 做个别人家的网页
- The problem of looting by leetcode
- Realization of commodity backstage system
- 痞子衡嵌入式:RT-UFL - 一个适用全平台i.MXRT的超级下载算法设计
- LinkedList源码简析
猜你喜欢
Can't find other people's problem to solve
Technical point 5: XML language
sql 截取数据中 ‘.’的前后数据
Prometheus安装配置
ERP的权限管理的操作与设计--开源软件诞生24
crm系统的成本一般是多少?
Just graduated will be confused, I after 7 years of summary, give programmers your 7 suggestions
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
推动中国制造升级,汽车装配车间生产流水线3D可视化
Can public IP address and SSL certificate improve SEO?
随机推荐
Unity使用transform.Rotate进行三维旋转角度出现偏差
How to implement LRU algorithm
Gets the property value of a column in the list collection object
痞子衡嵌入式:RT-UFL - 一个适用全平台i.MXRT的超级下载算法设计
input 与 button 的问题 (空隙/不等高/对不齐)及 解决办法
Exhibition cloud technology interpretation | in the face of emergencies, how does app do a good job in crash analysis and performance monitoring?
2020-11-09:谈谈布隆过滤器和布谷鸟过滤器的相同点和不同点?
公网IP地址和SSL证书可以提升SEO吗?
Prometheus installation configuration
Brief analysis of LinkedList source code
Error running app: default activity not found solution
【CentOS7操作系统安全加固系列】第(2)篇
“wget: 无法解析主机地址”的解决方法
November 09, 2020: talk about the similarities and differences between the bulon filter and the cuckoo filter?
Hengxun Technology: the way to deal with server downtime
Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法
推动中国制造升级,汽车装配车间生产流水线3D可视化
京淘项目day10
Jingtao project Day10
正式班D25