# -*- coding:utf-8 -*-
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# 返回从尾部到头部的列表值序列,例如[1,2,3]
def printListFromTailToHead(self, listNode):
# write code here
out=[]
head=listNode
while head!=None:
out.append(head.val)
head=head.next
out.reverse()
return out
python 从尾到头打印链表
最新推荐文章于 2022-05-30 22:28:28 发布