当前位置:网站首页>[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]所创,转载请带上原文链接,感谢
边栏推荐
- Hand in hand to teach you to use container service tke cluster audit troubleshooting
- Nodejs: handwritten koa Middleware
- 异常:Invalid or unexpected token
- Analysis steps of commodity background management
- 2020-11-09:谈谈布隆过滤器和布谷鸟过滤器的相同点和不同点?
- 探访2020 PG技术大会
- How to greatly improve the performance of larravel framework under php7? Install stone!
- 毕业即失业?大学生如何分配学习时间比例,拥有完整计算机知识体系?
- 没有磁盘空间 No space left on device
- CUDA_获取指定设备
猜你喜欢

京淘项目day10

Come and learn! Development Guide for personalized recommendation system (with internet disk link)

Guest interview: Wang Jian

IP地址SSL证书

Hengxun Technology: the way to deal with server downtime

做个别人家的网页

白山云科技入选2020中国互联网企业百强

How to carry out modular power operation efficiently

会展云技术解读 | 面对突发事故,APP 如何做好崩溃分析与性能监控?

js label语法跳出多重循环
随机推荐
日常页码样式问题
【CentOS7操作系统安全加固系列】第(2)篇
How much is the cost of CRM system?
剑指offer之打印超过数组一半的数字
LeetCode 50 Pow(x,n)
JT Jingtao project
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
jt-京淘项目
win7+vs2015+cuda10.2配置TensorRT7.0
JMeter的简单使用
白山云科技入选2020中国互联网企业百强
毕业设计之 ---基于微服务框架的电影院订票系统
2020-11-09:谈谈布隆过滤器和布谷鸟过滤器的相同点和不同点?
Common concepts and points for attention of CUDA
pytorch训练GAN时的detach()
编码风格:Mvc模式下SSM环境,代码分层管理
Centos7 operating system security hardening series (2)
LinkedList源码简析
C + + game development
推动中国制造升级,汽车装配车间生产流水线3D可视化