Very simple java solution for Binary Inorder Traversal using recursion, I learned this from my data structure course:)

  • 0
    public List<Integer> inorderTraversal(TreeNode root) {
    	List<Integer> list = new ArrayList<Integer>();
    	inOrder(root, list);
    	return list;
    public void inOrder(TreeNode node, List<Integer> list)
    	if(node == null) return;
    	inOrder(node.left, list);
    	inOrder(node.right, list);

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.