Leetcode的回文数问题,你能用长尾词描述吗?
- 内容介绍
- 文章标签
- 相关推荐
本文共计119个文字,预计阅读时间需要1分钟。
java/** * 9. Palindrome Number * Determine whether an integer is a palindrome. Do this without extra space. * @param x * @return */public static boolean isPalindrome(int x) { if (x de) { de=de * 10 + x % 10; x /=10; } return x==de || x==de / 10;}
PalindromeNumber.java/** * 9. Palindrome Number * Determine whether an integer is a palindrome. Do this without extra space. * @param x * @return */ public static boolean isPalindrome(int x) { if(x<0){ return false; } if(x<10){ return true; } int devF = 1; while(x / devF >= 10){ devF *= 10; } while(x>0){ int first = x/devF; int last = x%10; if(first!=last){ return false; } x = (x % devF) / 10; devF = devF/100; } return true; }
本文共计119个文字,预计阅读时间需要1分钟。
java/** * 9. Palindrome Number * Determine whether an integer is a palindrome. Do this without extra space. * @param x * @return */public static boolean isPalindrome(int x) { if (x de) { de=de * 10 + x % 10; x /=10; } return x==de || x==de / 10;}
PalindromeNumber.java/** * 9. Palindrome Number * Determine whether an integer is a palindrome. Do this without extra space. * @param x * @return */ public static boolean isPalindrome(int x) { if(x<0){ return false; } if(x<10){ return true; } int devF = 1; while(x / devF >= 10){ devF *= 10; } while(x>0){ int first = x/devF; int last = x%10; if(first!=last){ return false; } x = (x % devF) / 10; devF = devF/100; } return true; }

