leetcode--回文数
2019-04-01 17:34
127 查看
挺简单的
bool isPalindrome(int x) { if(x<0) return false; else { if(reverse(x) == -1) return false; if(x==reverse(x)) return true; else return false; } } int reverse(int x) { int INTMAX = pow(2,32) - 1; int num = 0; while(x!=0) { int m = x%10; x = x/10; if((num==INTMAX/10&&m>7)||num>INTMAX/10) return -1; num = num*10 + m; } return num; }
相关文章推荐
- LeetCode234_PalindromeLinkedList (判断是否为回文链表) Java题解
- LeetCode 9. 回文数
- leetcode5 最长回文子串
- [leetcode]5. 最长回文子串
- Leetcode 647. Palindromic Substrings 回文子串 解题报告
- leetcode:Palindrome Number 回文整数
- [LeetCode 125] - 验证回文(Valid Palindrome)
- LeetCode 5. Longest Palindromic Substring--最长回文子串
- 【LeetCode 214】最长回文子串
- leetcode 005 最长回文子串
- 【LeetCode】 String中的最长回文
- LeetCode 5. Longest Palindromic Substring(最长回文子串)
- Leetcode-680. Valid Palindrome II(判断回文)
- leetcode第5题,最长回文子串
- LeetCode 234 Palindrome Linked List(回文链表)(*)(?)
- LeetCode-409-Longest Palindrome(求字符串可组成的最长回文长度)
- 刷leetcode第五题-最长回文字符串
- Leetcode题解1:最长回文子串 JAVA
- LeetCode(Palindrome partition 2) 求将一个字符串划分成回文子串 需要分成的段数最少是多少
- LeetCode 234: Palindrome Linked List (回文链表)