实现二叉树先序,中序和后序遍历(递归方法实现)
public class Solution { /** * * @param root TreeNode类 the root of binary tree * @return int整型二维数组 */ public int[][] threeOrders (TreeNode root) { List list1=new ArrayList<>(); List list2=new ArrayList<>(); List list3=new ArrayList<>(); preOrder(root,list1); inOrder(root,list2); postOrder(root,list3); int[][] array=new int[3][list1.size()]; for(int a=0;a
共有 0 条评论