124. Binary Tree Preorder Traversal

Given the root of a binary tree root, return the node values in depth-first order: root — left — right (preorder).
Example 1
Input: root = [1]
Output: [1]
Explanation: A tree with one node.
Example 2
Input: root = [1,null,2,3]
Output: [1,2,3]
Explanation: Preorder: root, then left and right subtrees.
binary treeeasystacktree
JavaScript
Loading...
Line 1, Char 1