toastbin / DailyProblems

LeetCode
10 stars 2 forks source link

22.二叉树的前序遍历 #22

Open toastbin opened 4 years ago

toastbin commented 4 years ago

给定一个二叉树,返回它的 前序 遍历。

 示例:

输入: [1,null,2,3]  
   1
    \
     2
    /
   3 

输出: [1,2,3]

要求: 写出递归和迭代两种方式