94_二叉树的中序遍历[EASY]
约 129 字小于 1 分钟
2026-03-22
给定一个二叉树的根节点 root ,返回 它的 中序 遍历 。
示例 1: 
输入:root = [1,null,2,3]
输出:[1,3,2]示例 2:
输入:root = []
输出:[]示例 3:
输入:root = [1]
输出:[1]解题思路
中序遍历:左子树 -> 根节点 -> 右子树
Java实现
class Solution {
List<Integer> resultList = new ArrayList<>();
public List<Integer> inorderTraversal(TreeNode root) {
if (root == null){
return resultList;
}
inorderTraversal(root.left);
resultList.add(root.val);
inorderTraversal(root.right);
return resultList;
}
}