2025/10/16
思路:直接递归中序遍历
手写代码:
def inorder(T, results):
if T.left:
inorder(T.left, results)
results.append(T.val)
if T.right:
inorder(T.right, results)
inorder(T, [])
评价:简单直接,秒了
Binary Tree Inorder Traversal
思路:直接递归中序遍历
手写代码:
def inorder(T, results):
if T.left:
inorder(T.left, results)
results.append(T.val)
if T.right:
inorder(T.right, results)
inorder(T, [])
评价:简单直接,秒了