当前位置:网站首页>[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]所创,转载请带上原文链接,感谢
边栏推荐
- 探访2020 PG技术大会
- C++异常实现机制
- Hand in hand to teach you to use container service tke cluster audit troubleshooting
- Python调用飞书发送消息
- CUDA_主机内存
- 编码风格:Mvc模式下SSM环境,代码分层管理
- 推动中国制造升级,汽车装配车间生产流水线3D可视化
- Leetcode 49 letter heterotopic word grouping
- eleven point nine
- The number of more than half of the array is printed by the sword
猜你喜欢

毕业设计之 ---基于微服务框架的电影院订票系统

Make a home page

LinkedList源码简析

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

Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom

Hengxun Technology: the way to deal with server downtime

Exhibition cloud technology interpretation | in the face of emergencies, how does app do a good job in crash analysis and performance monitoring?

How to carry out modular power operation efficiently

What is the SRM system? SRM supplier management system functions

Win7 + vs2015 + cuda10.2 configuration tensorrt7.0
随机推荐
当我们开发一个接口时需要注意些什么
Unity使用transform.Rotate进行三维旋转角度出现偏差
pytorch训练GAN时的detach()
ES6, ES7, es8 Learning Guide
技术点5:XML语言
Must see! RDS database all in one
Postman(一)---功能介绍
C/C++编程笔记:C语言开发坦克大战!纪念我们逝去的小霸王游戏
Aikang Guobin denounced Guoxin Securities report as untrue and sent a lawyer's letter
算法模板整理(一)
Python调用飞书发送消息
Can't find other people's problem to solve
Can public IP address and SSL certificate improve SEO?
C++异常实现机制
CUDA_ Global memory and access optimization
会展云技术解读 | 面对突发事故,APP 如何做好崩溃分析与性能监控?
DB engines database ranking in November: PostgreSQL holds the top spot in the same period
C / C + + Programming Notes: C language development tank war! In memory of our lost little overlord game
异常:Invalid or unexpected token
What is the architecture of a live broadcast system worth more than $1 billion?