1class Solution:2def isPalindrome(self, head: "Optional[ListNode]") -> bool:3if head.next == None:4return True # if only 1 element, it's always a palindrome5forward = head6first_half = []7fast = head89while fast != None and fast.next != None:10first_half.append(forward.val)11forward = forward.next12fast = fast.next.next1314# forward should now be through half the list15if fast != None:16forward = forward.next # if length isn't even, skip the middle number1718reverse = len(first_half) - 119while forward != None:20if forward.val != first_half[reverse]:21return False22forward = forward.next23reverse -= 12425return True