天天看點

[LeetCode] Binary Tree Preorder Traversal

given a binary tree, return the preorder traversal of its nodes’ values.

for example:

given binary tree {1,#,2,3},

[LeetCode] Binary Tree Preorder Traversal

return [3,2,1].

note: recursive solution is trivial, could you do it iteratively?