/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public boolean isPalindrome(ListNode head) {
Boolean flag=true;
Stack stack = new Stack();
ListNode temp=head;
while(temp!=null){
stack.push(temp.val);
temp=temp.next;
}
while(head!=null){
int t=(int)stack.pop();
if(t!=head.val){
flag=false;
break;
}
head=head.next;
}
return flag;
}
}