1ms clean JAVA solution


  • 0
    public class Solution {
        public List<Integer> inorderTraversal(TreeNode root) {
            List<Integer> res = new LinkedList<Integer>();
            sol(root, res);
            return res;
        }
        
        public void sol(TreeNode cur, List<Integer> res) {
            if(cur == null) return;
            sol(cur.left, res);
            res.add(cur.val);
            sol(cur.right, res);
        }
    }
    

Log in to reply
 

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