首页 > 其他分享 >leetcode-94-easy

leetcode-94-easy

时间:2022-10-13 18:11:10浏览次数:42  
标签:return list List 94 public easy root leetcode

Binary Tree Inorder Traversal

public List<Integer> inorderTraversal(TreeNode root) {
    List<Integer> list = new ArrayList<>();
    t(root, list);
    return list;
}

public void t(TreeNode root, List<Integer> list) {
    if (root == null) return;

    t(root.left, list);
    list.add(root.val);
    t(root.right, list);
}

标签:return,list,List,94,public,easy,root,leetcode
From: https://www.cnblogs.com/iyiluo/p/16789182.html

相关文章