class Solution:
def reversePrint(self, head: ListNode) -> List[int]:
if not head:
return []
root = self.reverseLink(head)
cur = root
res = []
while cur:
res.append(cur.val)
cur = cur.next
self.reverseLink(root)
return res
def reverseLink(self, head: ListNode) :
dy = None
cur, tmp = head, head
while cur:
tmp = cur.next
cur.next = dy
dy, cur = cur, tmp
return dy
https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/