LeetCode 0009
来源:互联网 发布:网络高清硬盘播放机 编辑:程序博客网 时间:2024/05/16 01:37
原题链接
我的解法:我没有认真看题目,所以是转成string做的,显然是不可以的。
最快答案的做法:
首先考虑到负数一定不是回文数,因此给出一波判断。之后将给定的数字转置,然后判断转置前后的数字是否一致。
class Solution {public: bool isPalindrome(int x) { if(x<0) return false; int sum=0, y = x; while(x>0) { sum = sum*10+x%10; x = x/10; } return y == sum; }};
阅读全文
0 0
- LeetCode 0009
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- leetcode
- LEETCODE
- leetcode
- leetCode
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode:
- Spring Security(18)——Jsp标签
- Algorithm4——有序向量查找
- 论王者荣耀英雄花木兰
- Kali linux渗透测试(五)
- MQL5-字符串数据
- LeetCode 0009
- Spring Security(17)——基于方法的权限控制
- linux安转jdk1.8
- this指向,改变this指向
- luoguP2024 食物链 题解
- 28:单词倒排
- 个人风格在软件领域的形象
- 2017.09.23
- php 随机生成数字字母组合