Recursice Java Solution with runtime beating 96%


  • 0

    public class Solution {

    List<Integer> resultList= new LinkedList<Integer>();
    public List<Integer> inorderTraversal(TreeNode root) {
        if (root==null) 
           return resultList;
        
        inorderTraversal(root.left);
        resultList.add(root.val);
        inorderTraversal(root.right);
        return resultList;
    }
    

    }


Log in to reply
 

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