题解 | #从尾到头打印链表#
从尾到头打印链表
https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035
class Solution: def printListFromTailToHead(self , listNode: ListNode) -> List[int]: # write code here lk_list = [] while listNode: lk_list.append(listNode.val) listNode = listNode.next # 数组逆序返回 return lk_list[::-1]