/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public boolean isPalindrome(ListNode head) {
ArrayList<Integer> arr = new ArrayList<Integer>();
ListNode temp = head;
while(temp!=null){
arr.add(temp.val);
temp =temp.next;
}
for(int i = 0,j=arr.size()-1;i<=j;i++,j--){
if(arr.get(i) != arr.get(j)){
return false;
}
}
return true;
}
}