文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书
1. 问题描述
Given a binary tree, return the preorder traversal of its nodes’ values.
For example:
Given binary tree {1,#,2,3},
| 1 | 1 | 
return [1,2,3].
2. 求解
这个题就是一个树的先序遍历问题,最简单的方案就是递归的遍历子树,要注意递归退出的条件。
| 1 | /** | 
文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书
Given a binary tree, return the preorder traversal of its nodes’ values.
For example:
Given binary tree {1,#,2,3},
| 1 | 1 | 
return [1,2,3].
这个题就是一个树的先序遍历问题,最简单的方案就是递归的遍历子树,要注意递归退出的条件。
| 1 | /** | 
 
          微信打赏
 
          支付宝打赏