R7-链表篇

思路:
转回文数组法
链表转数组,再使用双指针判断是不是回文数组即可。
wkao?!根本不用双指针判断是否回文数组,只需要倒序判断布尔值即可。(牛啊牛啊)
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def isPalindrome(self, head: Optional[ListNode]) -> bool:
        ret=[]
        cur=head
        while cur is not None:
            ret.append(cur.val)
            cur=cur.next
        return ret==ret[::-1]


![[米联客-XILINX-H3_CZ08_7100] FPGA程序设计基础实验连载-24 TPG图像测试数据发生器设计](https://i-blog.csdnimg.cn/direct/96f5dbecc8654442a4ac28421b147546.png)
















