You are given the root of a binary tree. Your task is to return the preorder traversal of the tree. In preorder traversal, visit the root node first, then recursively traverse the left subtree followed by the right subtree.
Input: root = [1,null,2,3]
Output: [1,2,3]
Explanation: The nodes are visited in Root → Left → Right order.
Input: root = [4,2,6,1,3,5,7]
Output: [4,2,1,3,6,5,7]
Explanation: The preorder traversal visits the root before its subtrees.
Input: root = []
Output: []
Explanation: The tree is empty.
Sign in to write, run, and submit your solution against the full test suite.