给定节点数为 n 的二叉树的前序遍历和中序遍历结果,请重建出该二叉树并返回它的头结点。
题目遇到的问题:在于复制数组时,忘记相应的函数。arrays.copyofRange().
public class Solution { public TreeNode reConstructBinaryTree(int [] pre,int [] vin) { if(pre.length==0 || vin.length==0) return null; TreeNode root =new TreeNode(pre[0]); int loc=0; for (;loc欢迎分享,转载请注明来源:内存溢出
评论列表(0条)