题目大意
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
从前序和中序序列构建一棵树
题目分析
递归即可,这里用了Arrays.copyOfRange方法,最开始没用明白,如果传入参数有误会抛出异常。代码实现还不够优雅,以后有时间再改改
代码
|
|
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
从前序和中序序列构建一棵树
递归即可,这里用了Arrays.copyOfRange方法,最开始没用明白,如果传入参数有误会抛出异常。代码实现还不够优雅,以后有时间再改改
|
|