LeetCode 算法习题 第三周
来源:互联网 发布:1025实验室 知乎 编辑:程序博客网 时间:2024/06/05 15:20
Reverse Integer
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
题目大意
将一个整数进行位数调换,使得最高位成为个位,次高位成为十位,……
比如123 变成321
我的解答
class Solution {public: int reverse(int x) { int ans = 0; while (x) { int temp = ans * 10 + x % 10; if (temp / 10 != ans) return 0; ans = temp; x /= 10; } return ans; }};
阅读全文
0 0
- LeetCode 算法习题 第三周
- LeetCode 算法习题 第二周
- Leetcode 算法习题 第五周
- Leetcode 算法习题 第六周
- Leetcode 算法习题 第六周
- Leetcode 算法习题 第八周
- Leetcode 算法习题 第九周
- Leetcode 算法习题 第十周
- Leetcode 算法习题 第十二周
- Leetcode 算法习题 第十三周
- Leetcode 算法习题 第十三周
- Leetcode 算法习题 第十五周
- 第三周LeetCode算法题两道
- 算法竞赛第三章习题
- 第三周 习题
- LeetCode 算法习题 第一周
- LeetCode 算法习题 第四周
- LeetCode 算法习题 第四周
- 菜鸟手记(二)
- Revit中Dynamo编程——在Python中怎么利用RevitAPI来写一个过滤
- 定位系统环境变量
- bootstrap实现商品主页面 代码
- FME转换CAD至SHP,实现注记到多边形字段传递
- LeetCode 算法习题 第三周
- ST表简介 (洛谷P3865、洛谷P2251)
- python 下运行redis
- OHEM算法论文理解
- 数组中超过一半的数字
- Android有条件的设置横屏或竖屏
- 关于链表的倒数第k个结点的查找问题--考研题
- 2. 变量和基本类型
- Spark代码Eclipse远程调试