当前位置:网站首页>(闲暇)LeetCode_7. 整数反转
(闲暇)LeetCode_7. 整数反转
2022-07-21 09:15:00 【phac123】
题目链接:https://leetcode-cn.com/problems/reverse-integer/
学习点:
- 可以使用INT_MAX和INT_MIN
- 在这里溢出可以直接输出0
代码:
class Solution {
public:
int reverse(int x) {
long y = 0;
while(x) {
y = y * 10 + x % 10;
x /= 10;
}
return y > INT_MAX || y < INT_MIN ? 0 : y;
}
};
边栏推荐
猜你喜欢
6.< tag-动态规划和打家劫舍合集(树形DP)>lt.198.打家劫舍 + lt.213. 打家劫舍 II + lt.337. 打家劫舍 III dbc
奇葩!一公司面试题竟问如厕习惯、吃饭时长、入睡时间等
Sentinel理论知识与介绍
Neural network plus attention mechanism, accuracy does not rise but fall?
安全之路 —— 单管道反向连接后门解析
clip:learning transferable visual models from natural language supervision
腾讯 Techo Hub 2022 年首站落地福州|723,与开发者们探讨工业数字化!
编程语言之父们退休太无聊,纷纷选择重返职场
Sentinel容错规则持久化
C # use resx manager to switch between Chinese and English
随机推荐
07.01 哈夫曼树
3511. Water pouring problem
Hcip day 10 notes
Gateway整合Sentinel实现对路由的限流规则
ByteDance confirmation will be self-developed chip: for internal use only; Musk: I have uploaded my brain to the cloud; Go language product head leaves | geek headlines
AtCoder Beginner Contest 260 - C, D, E
Codeforces Round #808 (Div. 2) - A,B,C
Sentinel使用代码实现流控熔断降级规则
MQTT源码解析
mysql插入数据报错
Minor spanning tree
3625. Power
How to use the order flow analysis tool (Part 1)
mac M1安装的mysql,开启binlog
07.02 Huffman code
R语言ggplot2可视化:ggplot2可视化分组箱图,将可视化图像的图例(legend)放置在图像底部居中、其中图例信息水平平铺 (position legend bottom center)
【学习笔记】浅谈高斯整数
Common plug-ins of idea
网络安全和数据安全分不清?数据安全为何重要?
3564. Date category