【leetcode】Palindrome Number
2013-10-08 23:29
495 查看
class Solution { public: bool isPalindrome(int x) { // Note: The Solution object is instantiated only once and is reused by each test case. if(x<0) return false; if(x==0) return true; int oldVal=x; int newVal=0; while(x>0) { newVal=newVal*10+x%10; x/=10; } return oldVal==newVal; } };
相关文章推荐
- arrayfunction[LeetCode]Convert Sorted Array to Binary Search Tree
- LeetCode - Insertion Sort List
- [Leetcode] 4Sum
- LeetCode——01 Two Sum
- 【LeetCode with Python】 Combination Sum II
- LeetCode Word Search
- 【Leetcode】【Medium】Unique Binary Search Trees II
- leetcode004:Median of Two Sorted Arrays
- Minimum Size Subarray Sum —— LeetCode
- LeetCode - Largest Number (sort的cmp的写法)
- LeetCode 3 Longest Substring Without Repeating Characters 区间,想法 难度:1
- [leetcode]Palindrome Number
- leetcode -- Combination -- 重点,求可能的0,1全排列
- 80. Remove Duplicates from Sorted Array II LeetCode
- Leetcode no. 283
- leetcode 之Reverse Nodes in k-Group(22)
- leetcode343 Integer Break java
- LeetCode(3) Longest Substring Without Repeating Characters
- Leetcode-131. Palindrome Partitioning
- Leetcode 339 Nested List Weight Sum