public static boolean isPalindrome(int x) {
if(x<0) return false;
ArrayList<Character> chars = new ArrayList<>();
while(x>0){
chars.add((char)(x%10+'0'));
x = x/10;
}
int len_chars = chars.size();
for(int i=0; i<len_chars/2; i++){
if(chars.get(i) != chars.get(len_chars-i-1)){
return false;
}
}
return true;
}
Quiz
Q1: What is the main topic covered in "leetcode_9_Palindrome_Number"?
leetcode_9_Palindrome_Number
Q2: What are the key takeaways from this article?
leetcode_9_Palindrome_Number
Q3: How can the concepts in this article be applied in practice?
Consider the practical examples and patterns discussed throughout the post.