<s> class Solution : <EOL> def isPalindrome ( self , head ) : <EOL> reverse , fast = None , head <EOL> while fast and fast . next : <EOL> fast = fast . next . next <EOL> head . next , reverse , head = reverse , head , head . next <EOL> tail = head . next if fast else head <EOL> is_palindrome = True <EOL> while reverse : <EOL> is_palindrome = is_palindrome and reverse . val == tail . val <EOL> reverse . next , head , reverse = head , reverse , reverse . next <EOL> tail = tail . next <EOL> return is_palindrome </s>
