public boolean isPalindrome(ListNode head) {
        if (head == null || head.next == null)
            return true;
        ListNode slow = head, fast = head;
        while (fast.next != null && fast.next.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        ListNode newNode = reverse(slow.next);
        slow.next = null;
        while (newNode != null) {
            if (head.val != newNode.val)
                return false;
            head = head.next;
            newNode = newNode.next;
        }
        return true;
    }