当前位置:网站首页>链表5 - 234. 回文链表

链表5 - 234. 回文链表

2022-06-23 11:39:00 人工智能曾小健

 

class Solution:
    def isPalindrome(self,head:ListNode) -> bool:
        vals= []
        current_node =head
        while current_node is not None:
            vals.append(current_node.val)
            current_node = current_node.next
        return vals ==vals[::-1]
class Solution:
    def isPalindrome(self,head:ListNode) ->bool:
        vals= []
        current_node =head
        while current_node is not None:
            vals.append(current_node.val)
            current_node = current_node.next
        return vals ==vals[::-1]

原网站

版权声明
本文为[人工智能曾小健]所创,转载请带上原文链接,感谢
https://blog.csdn.net/sinat_37574187/article/details/125418581