版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22795513/article/details/80663393
class Solution(object):
def isPalindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
list1 = []
list2 = []
if head == None:
return True
while head:
list1.append(head.val)
list2.append(head.val)
head = head.next
list1.reverse()
if list1 == list2:
return True
else:
return False