← 返回 linkedin 的题目列表Binary Tree Traversal using Iterative and Recursive Methods
类型:online_judge
Given a binary tree, implement both iterative and recursive methods for preorder traversal, and return all paths from root to leaf nodes. Implement binary_tree_paths_recursive(root: TreeNode) -> List[str] and binary_tree_paths_iterative(root: TreeNode) -> List[str].
Example
Input
Example binary tree setup