Recursive Solution: Must see


#1

public class Solution {
public int[] inorderTraversal(TreeNode A) {
ArrayList list=new ArrayList();
inorder(A,list);
int[] arr=new int[list.size()];
for(int i=0;i<list.size();i++){
arr[i]=list.get(i);
}
return arr;
}
private void inorder(TreeNode A, ArrayList list){
if(A==null){
return;
}

inorder(A.left,list);
list.add(A.val);
inorder(A.right,list);

}

}


#2

You are not allowed to use recursion.