题目描述:
给定一个二叉树的根节点 root ,返回它的 中序 遍历。
class Solution{
public List<Integer>inorderTraversal(TreeNode root){
List<Integer>res=new ArrayLsit<Integer>();
inorder(root,res);
return res;
}
public void inorder(TreeNode root,List<Integer>res){
if(root==null){
return;
}
inorder(root.left,res);
res.add(root.val);
inorder(root.right,res);
}
}