LeetCode-9-Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.
判断一个整数是否是回文数。
思路:求出数字abcd的逆序的数值dcba,如果是回文数的话,那么abcd==dcba。
时间复杂度:O(n)
python代码:
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
temp = x
revert_x = 0
while temp > 0:
revert_x = revert_x*10 + temp % 10
temp //= 10
return revert_x == x
LeetCode-9-Palindrome Number的更多相关文章
- Leetcode练习题 Palindrome Number
9. Palindrome Number Question: Determine whether an integer is a palindrome. An integer is a palindr ...
- Leetcode 9. Palindrome Number(水)
9. Palindrome Number Easy Determine whether an integer is a palindrome. An integer is a palindrome w ...
- leetcode 9 Palindrome Number 回文数
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...
- LeetCode 9. Palindrome Number (回文数字)
Determine whether an integer is a palindrome. Do this without extra space. 题目标签:Math 题目给了我们一个int x, ...
- Leetcode 9. Palindrome Number(判断回文数字)
Determine whether an integer is a palindrome. Do this without extra space.(不要使用额外的空间) Some hints: Co ...
- [LeetCode][Python]Palindrome Number
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/palindr ...
- 蜗牛慢慢爬 LeetCode 9. Palindrome Number [Difficulty: Easy]
题目 Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could nega ...
- [LeetCode] 9.Palindrome Number - Swift
Determine whether an integer is a palindrome. Do this without extra space. 题目意思:判断一个整数是否是回文数 例如:1232 ...
- [LeetCode] 9. Palindrome Number 验证回文数字
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...
- 【leetcode】Palindrome Number
题目简述: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could n ...
随机推荐
- JS+HTML5的Canvas画图模拟太阳系运转
查看效果:http://hovertree.com/texiao/html5/9.htm 地球自传 http://hovertree.com/texiao/html5/8.htm 代码如下: < ...
- 2-1 git合并 打tag
tag常用命令(仅供参考): git tag -a V1.4 -m "1.4" 创建一个tag git tag 查看本地tag git tag -d V1.1 删除本地tag g ...
- Mou常用快捷键
title: Mou常用快捷键date: 2015-11-08 17:16:38categories: 编辑工具 tags: mou 小小程序猿我的博客:http://daycoding.com Vi ...
- ToolWindow工具类
package com.dute.dutenews.utils; import android.app.Activity; import android.content.Context; import ...
- AtomicInteger源码注释
AtomicInteger源码 在java.util.concurrent.atomic包下提供了大量的原子类,这里以AtomicInteger源码为例,添加了一些注释,个人理解,供参考: 其中比较重 ...
- vim中tab转为空格
:set ts=4:set expandtab:%retab!
- Provider:SSL Provider,error:0-等待的操作过时
今天一同事使用SSMS 2012 连接数据库时,遇到了"provider:SSL Provider,error:0-等待的操作过时",搜索了一下,遇到一哥 们也遇到这个问题:SQL ...
- 看懂Oracle执行计划
最近一直在跟Oracle打交道,从最初的一脸懵逼到现在的略有所知,也来总结一下自己最近所学,不定时更新ing- 一:什么是Oracle执行计划? 执行计划是一条查询语句在Oracle中的执行过程或访问 ...
- [iOS]坑爹的ALAsset(Assets Library Framework)
Assets Library Framework 可以用来做iOS上的多选器,选照片视频啥的啦就不介绍了. 目前的项目有点类似dropbox,可以选择设备内的照片然后帮你上传文件,使用了Assets ...
- Fragment 与Activity
一个Activity 对应 多个Fragment; 每一个类 extends Fragment , 一个Activity 可以同时显示多个 Fragment; Fragment是依赖于Activity ...