leetcode系列(23)判断整数是不是回文
来源:互联网 发布:动漫制作软件 编辑:程序博客网 时间:2024/06/14 07:55
判断一个整数是不是回文,且不用额外的空间,这个很简单,就是把一个整数翻转一下,跟itoa非常相似。直接上代码吧
class Solution {public: bool isPalindrome(int x) { if (x < 0) { return false; } int num = x; int new_num = 0; while (num) { int tmp = num / 10; new_num = 10 * new_num + (num - tmp * 10); num = tmp; } return x == new_num; }};
class Solution: # @param {integer} x # @return {boolean} def isPalindrome(self, x): if x < 0: return False num = int(x) new_num = 0; while num > 0: new_num = 10 * new_num + int(num % 10) num = int(num / 10) return x == new_num
0 0
- leetcode系列(23)判断整数是不是回文
- 判断一个整数是不是回文
- 判断输入的整数是不是回文数
- 判断一个整数是不是回文数
- 怎样判断一个整数是不是回文数?
- 2.leetcode-判断一个数字是不是回文
- leetcode Palindrome Number (判断整数是否为回文)
- [LeetCode]-Palindrome Number 判断整数回文
- 判断字符是不是回文
- 判断是不是回文数
- 判断字符串是不是回文
- 判断是不是回文
- 判断是不是回文数
- 判断是不是回文数
- 判断字符串是不是回文
- C#判断是不是回文
- 判断一个字符串是不是对称(是不是回文字符串)
- leetcode系列(16)判断链表是否为回文
- myeclipse javaWeb项目+JAX-WS webService接口开发
- 欢迎使用CSDN-markdown编辑器
- 维特比算法在分词中的应用
- centos下的压缩解压缩
- 算法学习之一java实现堆排序
- leetcode系列(23)判断整数是不是回文
- uCosIII中使用malloc函数
- emacs org plot 绘图二 折线图
- 求矩阵中的最大二维矩阵
- Java造型中的强制转换
- WDK显卡驱动sample编译和部署
- 显示意图和隐式意图
- 马哥linux2014|2015全套教程
- Monkey 测试