当前位置:网站首页>[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]所创,转载请带上原文链接,感谢
边栏推荐
- Optimization of commodity backstage system
- Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
- 商品后台管理实现分析步骤
- The problem of looting by leetcode
- 快来学习!个性化推荐系统开发指南(附网盘链接)
- 当我们开发一个接口时需要注意些什么
- Nodejs: handwritten koa Middleware
- SRM系统是什么系统?SRM供应商管理系统功能
- ES6、ES7、ES8学习指南
- Interviewer: what are cache penetration, cache avalanche and cache breakdown?
猜你喜欢

Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
![Usage of [:] and [::] in Python](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Usage of [:] and [::] in Python

面试官:缓存穿透、缓存雪崩和缓存击穿是什么?

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

将Map中对应的key和value赋值到对象中

CUDA_共享内存、访存机制、访问优化

Must see! RDS database all in one

How much is the cost of CRM system?

价值超10亿美元的直播系统架构图是什么样子的?

C++异常实现机制
随机推荐
面试官:缓存穿透、缓存雪崩和缓存击穿是什么?
How much is the cost of CRM system?
Aikang Guobin denounced Guoxin Securities report as untrue and sent a lawyer's letter
Optimization of commodity backstage system
C/C++编程笔记:C语言开发坦克大战!纪念我们逝去的小霸王游戏
白山云科技入选2020中国互联网企业百强
利用尾巴作为时间序列进行处理来识别鲸鱼
一幅图像能顶16x16字!——用于大规模图像缩放识别的变压器(对ICLR 2021年论文的简要回顾)
crm系统的成本一般是多少?
Prometheus installation configuration
The problem of looting by leetcode
“wget: 无法解析主机地址”的解决方法
Visit 2020 PG Technology Conference
eleven point nine
DB engines database ranking in November: PostgreSQL holds the top spot in the same period
CUDA_全局内存及访问优化
Technical point 5: XML language
CUDA_获取指定设备
jt-京淘项目
ERP的权限管理的操作与设计--开源软件诞生24