234. Palindrome Linked List
Last updated
Last updated
class Solution:
def isPalindrome(self, head: Optional[ListNode]) -> bool:
s = ""
t = ""
def recursion(head):
nonlocal s
nonlocal t
if not head:
return
s += str(head.val)
recursion(head.next)
t += str(head.val)
recursion(head)
return s == t