classSolution: defisPalindrome(self, head: ListNode) -> bool: slow,fast,prev = head,head,None while fast isnotNone: slow = slow.next fast = fast.next.next if fast.next isnotNoneelse fast.next while slow isnotNone: slow.next, slow, prev= prev, slow.next, slow while head and prev: if head.val != prev.val: returnFalse head = head.next prev = prev.next returnTrue