/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) {} };*/ class PalindromeList { public: bool chkPalindrome(ListNode* A) { // write code here stack<ListNode> st; ListNode * p = A; while(p) { st.push(*p); p=p->next; } p = A; while(p) { ListNode N = st.top(); if(p->val==N.val) { st.pop(); p = p->next; } else { return false; } } return true; } };