输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。
解题思路:利用递归的性质遍历链表,将遍历的结果放入一个队列中。
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reversePrint(self, head):
"""
:type head: ListNode
:rtype: List[int]
"""
if head:
return self.reversePrint(head.next)+[head.val]
else:
return []



