In-order traversal of binary tree
1. In-order traversal of binary tree
2. My initial thoughts and problems
Slightly, look directly at the idea and solution of force buckle
3. Problem solving method one: recursion
class Solution {
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> res = new ArrayList<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);
}
}