144. Binary Tree Preorder Traversal

Practice Binary Tree Preorder Traversal for free on NudgeCode: Easy, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return the values of a binary tree in preorder: the node itself first, then its left subtree, then its right subtree.

Example

root = [1,null,2,3]  ->  [1,2,3]

Constraints