Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-17_11-53-16.png
39 KB
#N234. Palindrome Linked List
problem link

#solution
class Solution {
public boolean isPalindrome(ListNode head) {
List<Integer> arr=new ArrayList<>();
ListNode curr=head;

while(curr!=null){
arr.add(curr.val);
curr=curr.next;
}

for(int i=0; i<arr.size()/2; i++){
if(arr.get(i)!=arr.get(arr.size()-i-1))
return false;

}

return true;
}
}