The idea is simple. Reverse the first half of the linked list and compare it to the second half.

```
def isPalindrome(self, head):
count = 0
node = head
while node:
node = node.next
count += 1
node = head
pre = None
for i in range(count // 2):
temp = node.next
node.next = pre
pre = node
node = temp
if count % 2 == 0:
h2 = node
else:
h2 = node.next
h1 = pre
while h1:
if h1.val == h2.val:
h1 = h1.next
h2 = h2.next
else:
return False
return True
```