Simple Solution using Stack


#1
public ArrayList<Integer> inorderTraversal(TreeNode A) {

    Stack<TreeNode> st = new Stack<>();
    ArrayList<Integer> res = new ArrayList<>();
    while(true){
        if(A!=null){
            st.push(A);
            A=A.left;
        } else {
            if(st.isEmpty()){
                break ;
            }
            A = st.pop();
            res.add(A.val);
            A = A.right ;

        }
    }

    return res ;
    
}