/*
struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};*/
#include <string>
class Palindrome {
public:
    bool isPalindrome(ListNode* pHead) {
        // write code here
        if (!pHead || !pHead->next) {
            return true;
        }
        string sHead;
        auto ph = pHead;
        while(ph){
            sHead += to_string(ph->val);
            ph=ph->next;
        }
        size_t len = sHead.length();
        for(size_t i =0;i<len;++i){
            if(sHead[i] !=sHead[len-i-1])
            return false;
        }
        return true;
    }
};