Skip to content

Commit

Permalink
Create Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Jun 23, 2017
1 parent cd886f0 commit 14126f0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tree/545.Boundary-of-Binary-Tree/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### 545.Boundary-of-Binary-Tree

需要分别写子函数遍历左边界、底部叶子节点、右边界。

对于左边界,注意题目要求,当根节点没有左子树时,左边界就只是根。所以,遍历左边界的函数其实可以从root->left开始。同理,遍历右边界的函数可以从root->right开始。左边界、右边界求完后,都要各自pop_back(),为叶子节点数组腾出重复的节点位置。

另外,遍历底部叶子节点,需要注意仅有根节点的情况,这时不算有叶子节点。

最终结果就是:根 + 左边界(弹出最后一个)+ 所有叶子节点(不包括根)+ 右边界的反序(弹出最后一个)。

0 comments on commit 14126f0

Please sign in to comment.