Skip to content

Latest commit

 

History

History

144. Binary Tree Preorder Traversal

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

144. Binary Tree Preorder Traversal

Given the root of a binary tree, return the preorder traversal of its nodes' values.

Screen Shot 2022-01-18 at 7 54 28

Input: root = [1,null,2,3]
Output: [1,2,3]

Example 2:

Input: root = []
Output: []

Example 3:

Input: root = [1]
Output: [1]

Constraints:

The number of nodes in the tree is in the range [0, 100].
-100 <= Node.val <= 100