class Solution {
public List<Integer> inorderTraversal(TreeNode root) {
ArrayList<Integer> res = new ArrayList<>();
if(root == null){
return res;
}
inorder(root,res);
return res;
}
public void inorder(TreeNode root,ArrayList<Integer> res){
if(root.left != null) {
inorder(root.left, res);
}
res.add(root.val);
if(root.right != null){
inorder(root.right,res);
}
}
}
4/17/26Less than 1 minute