当前位置:网站首页>Niuke-top101-bm340
Niuke-top101-bm340
2022-07-28 03:00:00 【A fish that eats cats】
import java.util.*;
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */
public class Solution {
public TreeNode reConstructBinaryTree(int [] pre,int [] vin) {
int n = pre.length;
int m = vin.length;
if(n == 0 || m == 0){
return null;
}
TreeNode t = new TreeNode(pre[0]);
for(int i = 0; i < vin.length; i++){
if(pre[0] == vin[i]){
t.left = reConstructBinaryTree(Arrays.copyOfRange(pre, 1, i+1), Arrays.copyOfRange(vin, 0, i));
t.right = reConstructBinaryTree(Arrays.copyOfRange(pre, i+1, pre.length), Arrays.copyOfRange(vin, i+1, vin.length));
break;
}
}
return t;
}
}
边栏推荐
- unordered_ The hash function of map and the storage mode of hash bucket
- Pycharm 快速给整页全部相同名称修改的快捷键
- CSDN TOP1“一个处女座的程序猿“如何通过写作成为百万粉丝博主?
- IO流:节点流和处理流详细归纳。
- @The function of valid (cascade verification) and the explanation of common constraint annotations
- One month's experience of joining Huawei OD
- [signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code
- [self growth website collection]
- GBase8s如何在有外键关系的表中删除数据
- [leetcode] 13. linked list cycle · circular linked list
猜你喜欢
随机推荐
style=“width: ___“ VS width=“___“
1313_ Pyserial installation and document generation
[tutorial of using idea] shortcut key of idea
Using pytorch's tensorboard visual deep learning indicators | pytorch series (25)
TFX airflow experience
【微信小程序开发(五)】接口按照根据开发版体验版正式版智能配置
P6118 [joi 2019 final] solution to the problem of Zhenzhou City
Hardware standard
@The function of valid (cascade verification) and the explanation of common constraint annotations
Consolidate the data foundation in the data center
阿憨的故事
分布式事务——Senta(一)
Explanation of CNN circular training | pytorch series (XXII)
智能工业设计软件公司天洑C轮数亿元融资
【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
Typescript (zero) -- introduction, environment construction, first instance
Trivy [1] tool scanning application
mysql 随笔
分布式 session 的4个解决方案,你觉得哪个最好?
Constant power wireless charging based on stm32









