AC Java Solution using recursion


  • 0
    D
    public class Solution {
        List<Integer> st = new ArrayList<Integer>();  
        public List<Integer> inorderTraversal(TreeNode root) {
            if(root == null) return st;  
            if(root.left != null) inorderTraversal(root.left);  
            st.add(root.val);  
            if(root.right != null) inorderTraversal(root.right);  
            return st;
        }
    }

Log in to reply
 

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