当前位置:网站首页>[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]所创,转载请带上原文链接,感谢
边栏推荐
- 京淘项目day10
- 接缝雕刻算法:一种看似不可能的图像大小调整方法
- How to carry out modular power operation efficiently
- 获取List集合对象中某一列属性值
- 获取List集合对象中某一列属性值
- CUDA_ Register and local memory
- 商品后台管理实现分析步骤
- SQL intercepts the data before and after the '.'
- 那么当下的行情投资者该怎么办呢? 现在新的投资风口来了!
- Baishan cloud technology is selected as the top 100 Internet enterprises in China in 2020
猜你喜欢

Hengxun Technology: the way to deal with server downtime

推动中国制造升级,汽车装配车间生产流水线3D可视化

Python prompt attributeerror or depreciation warning: This module was degraded solution

飞鸽传书局域网找不到其他人的问题解决

November 09, 2020: talk about the similarities and differences between the bulon filter and the cuckoo filter?

IP地址SSL证书

SRM系统是什么系统?SRM供应商管理系统功能

Prometheus installation configuration

Postman (1) -- function introduction
![Usage of [:] and [::] in Python](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Usage of [:] and [::] in Python
随机推荐
CUDA_ Global memory and access optimization
CUDA_寄存器和局部存储器
Algorithm template arrangement (1)
Hengxun Technology: the way to deal with server downtime
How to make a set of K reverse linked lists
Functional guide for temporary users and novices of PL / SQL developer
SSL证书和公网IP地址如何影响SEO
How SSL certificate and public IP address affect SEO
sql 大小写转换,去掉前后空格
商品后台管理实现分析步骤
CUDA_ Shared memory, memory access mechanism, access optimization
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
DB engines database ranking in November: PostgreSQL holds the top spot in the same period
No space left on device
mongodb内核源码实现、性能调优、最佳运维实践系列-command命令处理模块源码实现一
Can't find other people's problem to solve
Important components of Apache Hadoop
C++异常实现机制
How to implement LRU algorithm
PLSQL Developer常用设置