Skip to main content

94. Binary Tree Inorder Traversal

分析

模版题

题解

function inorderTraversal(root: TreeNode | null): number[] {
const res: number[] = []

const dfs = (node) => {
if (!node) {
return
}
dfs(node.left)
res.push(node.val)
dfs(node.right)
}

dfs(root)

return res
};