# 二叉树的层序遍历 II

给定一个二叉树,返回其节点值自底向上的层序遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)

例如:
给定二叉树 [3,9,20,null,null,15,7],

    3
   / \
  9  20
    /  \
   15   7

返回其自底向上的层序遍历为:

[
  [15,7],
  [9,20],
  [3]
]
## template ```python class Solution(object): res = dict() def forwardSearch(self, root, depth): if root != None: if depth not in self.res.keys(): self.res[depth] = [] self.res[depth].append(root.val) self.forwardSearch(root.left, depth + 1) self.forwardSearch(root.right, depth + 1) def levelOrderBottom(self, root): self.forwardSearch(root, 1) result = [] self.dic = dict() for i in self.res.keys(): result.append(self.res[i]) return result[::-1] ``` ## 答案 ```python ``` ## 选项 ### A ```python ``` ### B ```python ``` ### C ```python ```