标签:insert next 代码 src space image col 打印 nts

思路:相当于数据结构中的链表就地逆置,可以使用头插法来实现。
代码:
class Solution:    # 返回从尾部到头部的列表值序列,例如[1,2,3]    def printListFromTailToHead(self, listNode):        # write code here        l = []        head = listNode        while head:            l.insert(0, head.val)            head = head.next        return l
标签:insert next 代码 src space image col 打印 nts
原文地址:https://www.cnblogs.com/wobushangwangl/p/10922545.html