/**
 * struct ListNode {
 *	int val;
 *	struct ListNode *next;
 * };
 */
/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param head ListNode类 the head
 * @return bool布尔型
 */
bool isPail(struct ListNode* head ) {
    // write code here
    int Vaule[100000] = {0};
    struct ListNode* Cur = head;
    int i = 0;
    while (Cur) { // 将链表节点的值记录在数组中;
        Vaule[i] = Cur->val;
        Cur = Cur->next;
        i++;
    }
    Cur = head;
    struct ListNode* Pre = NULL;
    struct ListNode* Next = head->next;
    // 将链表逆序;
    while (Cur) {
        Cur->next = Pre;
        Pre = Cur;
        Cur = Next;
        Next = Next->next;
    }
    // 此时 Pre 为链表逆序后的头指针
    int j = 0;
    while(Pre) // 逆序检查节点值是否匹配
    {
        if (Vaule[j] != Pre->val) {
            return false;
        }
        j++;
        Pre = Pre->next;
    }
    return true;
}