【leetcode题解】【28】【E】Palindrome Number
2015-12-06 21:25
387 查看
class Solution(object): def isPalindrome(self, x): l = 1 if x < 0 : return False #x = 0 - x while x / (pow(10,l)): l += 1 #print l a = 1 b = pow(10,l-1) for i in range(0,l/2): #print i,l-i-1 if x/a%10 == x/b%10: a *= 10 b /= 10 continue else: return False return True """ :type x: int :rtype: bool """
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Subscribe to see which companies asked this question
求一个数字是不是回文,
采用求幂和取余,按位比较
相关文章推荐
- 网络云盘的存储机制
- nyoj203(迪杰斯特拉+01背包)
- php底层HashTable的实现
- 自定义划线方法
- iOS:友盟SDK分享
- 信息安全系统设计基础第十三周学习总结——20135308
- 优秀开发地址 (包含前段,android 性能优化 以及react native)
- 图像处理领域的大牛
- linux下 lvm 磁盘扩容
- Spring mvc
- 如何在eclipse上使用egit插件
- Spring Boot自定义错误页面,Whitelabel Error Page处理方式
- properties类
- Android Studio的更新
- 产生冠军2094
- 我的序——科学与人文
- LeetCode 之 Reverse Integer
- Linux LVM硬盘管理及LVM扩容
- Python小爬虫练习
- 3 决策树(一)