当前位置:网站首页>[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]所创,转载请带上原文链接,感谢
边栏推荐
- How much is the cost of CRM system?
- C/C++编程笔记:C语言开发坦克大战!纪念我们逝去的小霸王游戏
- IP地址SSL证书
- The movie theater booking system based on micro Service Framework
- CUDA_常量内存
- Assign the corresponding key and value in the map to the object
- SQL case conversion, remove the space before and after
- Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
- pytorch训练GAN时的detach()
- C + + game development
猜你喜欢

Dongge ate grapes when he ate an algorithm problem!

Interviewer: what are cache penetration, cache avalanche and cache breakdown?

Analysis steps of commodity background management

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

Prometheus安装配置

接缝雕刻算法:一种看似不可能的图像大小调整方法

Unity使用transform.Rotate进行三维旋转角度出现偏差

Function calculation advanced IP query tool development

sql 截取数据中 ‘.’的前后数据

Hengxun Technology: the way to deal with server downtime
随机推荐
C / C + + Programming Notes: C language development tank war! In memory of our lost little overlord game
crm系统的成本一般是多少?
Usage of [:] and [::] in Python
没有磁盘空间 No space left on device
sql 大小写转换,去掉前后空格
会展云技术解读 | 面对突发事故,APP 如何做好崩溃分析与性能监控?
价值超10亿美元的直播系统架构图是什么样子的?
jt-京淘项目
How much is the cost of CRM system?
Mongodb kernel source code implementation, performance tuning, best operation and maintenance practice series command processing module source code implementation 1
团灭 LeetCode 打家劫舍 问题
Can't find other people's problem to solve
利用尾巴作为时间序列进行处理来识别鲸鱼
SQL filter query duplicate columns
LinkedList源码简析
Problems of input and button (GAP / unequal height / misalignment) and Solutions
How SSL certificate and public IP address affect SEO
Unity使用transform.Rotate进行三维旋转角度出现偏差
Python prompt attributeerror or depreciation warning: This module was degraded solution
No space left on device