题目链接
https://leetcode.com/problems/binary-tree-level-order-traversal-ii/
题目原文
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ \
9 20
/ \
15 7
return its bottom-up level order traversal as:
[
[15,7],
[9,20],
[3]
]
题目翻译
给定一个二叉树,返回其从下到上的层序遍历(从左到右,从下到上)。
思路方法
这道题实际上完全可以先得到从上到下的层序遍历,再逆序结果,但这样就没意思了,所以应该尝试避免reverse操作。不过方法还是类似的。
相关问题:102. Binary Tree Level Order Traversal [easy] (Python)
思路一
用队列来实现BFSÿ