【leetcode】 9. palindrome number
@requires_authorization
@author johnsondu
@create_time 2015.7.13 9:48
@url [palindrome-number](https://leetcode.com/problems/palindrome-number/)
/************************
* 分离出最左边和最右边的数
* 然后依次对照就可以
***********************/
class Solution {
public:
bool isPalindrome(int x) {
if(x < 0) return false;
if(x < 10) return true;
int base = 1;
while(x / base >=10) base *= 10;
while(x)
{
int ld = x / base;
int rd = x % 10;
if(ld != rd) return false;
x -= ld * base;
x /= 10;
base /= 100;
}
return true;
}
};【leetcode】 9. palindrome number的更多相关文章
- 【LeetCode】9. Palindrome Number (2 solutions)
Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. click t ...
- 【LeetCode】9. Palindrome Number 回文数
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:回文数,回文,题解,Leetcode, 力扣,Python ...
- 【leetcode】9. Palindrome Number
题目描述: Determine whether an integer is a palindrome. Do this without extra space. 解题分析: ^_^个人觉得这道题没有什 ...
- 【LeetCode】009. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...
- 【LeetCode】9 Palindrome Number 回文数判定
题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could neg ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
- 【LeetCode】137. Single Number II 解题报告(Python)
[LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...
- 【LeetCode】306. Additive Number 解题报告(Python)
[LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http: ...
- 【LeetCode】452. Minimum Number of Arrows to Burst Balloons 解题报告(Python)
[LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https ...
随机推荐
- 【CF540D】 D. Bad Luck Island (概率DP)
D. Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- POJ2104 K-th Number 不带修改的主席树 线段树
http://poj.org/problem?id=2104 给定一个序列,求区间第k小 通过构建可持久化的点,得到线段树左儿子和右儿子的前缀和(前缀是这个序列从左到右意义上的),然后是一个二分的ge ...
- BZOJ 2959: 长跑 lct 双联通分量 并查集 splay
http://www.lydsy.com/JudgeOnline/problem.php?id=2959 用两个并查集维护双联通分量的编号和合并. #include<iostream> # ...
- Loj #6560 小奇取石子
题面 分类讨论一波,n小的暴力2^n,n大的背包. #include<bits/stdc++.h> #define ll long long using namespace std; co ...
- 【漏洞预警】Apache ActiveMQ Fileserver远程代码执行漏洞(CVE-2016-3088)
漏洞编码:CVE-2016-3088 实验环境:Linux Apache ActiveMQ版本号:Apache ActiveMQ 5.7.0 ----------------------------- ...
- hdu 4560 拆点最大流 ***
题意: 2013年一开始,一档音乐节目“我是歌手”就惊艳了大家一回.闲话少说,现在,你成为了这档节目的总导演,你的任务很简单,安排每一期节目的内容. 现 在有N个歌手,M种歌曲流派(Rock,Pop之 ...
- sgu 194 上下界网络流可行流判定+输出可行流
#include <cstdio> #include <cstring> #define min(a,b) ((a)<(b)?(a):(b)) #define oo 0x ...
- Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate
C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standa ...
- POJ 1654 Area 计算几何
#include<stdio.h> #include<string.h> #include<iostream> #include<math.h> usi ...
- 回顾下$.ajax()方法参数
1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如 ...