# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#
#
# @param head ListNode类 the head
# @return bool布尔型
#
class Solution:
def isPail(self , head ):
# write code here
if not head or not head.next:
return True
stack = []
temp = head
while temp:
stack.append(temp)
temp = temp.next
temp = head
while temp:
top = stack.pop()
if top.val != temp.val:
return False
temp = temp.next
return True