144_Binary Tree Preorder Traversal
144. Binary Tree Preorder Traversal
Level: medium
Tag: tree, stack
Question
Given a binary tree, return the preorder traversal of its nodes' values.Example 1
Given binary tree [1,null,2,3],
1
\
2
/
3
return [1,2,3]Solution 1: recursive
Another version (w/o defining a helper function)
Solution 2: itratively
Last updated
Was this helpful?