Python 20ms Classic Implementation
Runtime: 20 ms, faster than 98.55% of Python3 online submissions for Binary Tree Preorder Traversal.\nMemory Usage: 14.1 MB, less than 99.97% of Python3 online 
Runtime: 20 ms, faster than 98.55% of Python3 online submissions for Binary Tree Preorder Traversal.\nMemory Usage: 14.1 MB, less than 99.97% of Python3 online submissions for Binary Tree Preorder Traversal.\n\n```\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def preorderTraversal(self, root: TreeNode) -> List[int]:\n        self.ans=[]\n        def preorder(root):\n            if root is None:\n                return\n            self.ans.append(root.val)\n            preorder(root.left)\n            preorder(root.right)\n        preorder(root)\n        return self.ans\n```
[]