当前位置:网站首页>617. merge binary tree
617. merge binary tree
2022-06-11 06:29:00 【Saucey_ six】
subject :
Answer key :
Ideas :(1) recursive (2) The tree is traversed in sequence , Set up null The node of is 0, Add two numbers
Code :
// recursive
var mergeTrees = function (t1, t2) {
if (t1 === null) return t2;
if (t2 === null) return t1;
t1.val += t2.val;
t1.left = mergeTrees(t1.left, t2.left);
t1.right = mergeTrees(t1.right, t2.right);
return t1;
};
(ps: Fifth day )
边栏推荐
- Autojs, read one line, delete one line, and stop scripts other than your own
- Eureka集群搭建
- jenkins-用户权限管理
- Markdown + typora + picgo experimental report template attached
- Teach everyone how to implement an electronic signature
- How to arrange the dataframe from small to large according to the absolute value of a column?
- go的fmt包使用和字符串的格式化
- Notes sur les questions d'entrevue de la FPGA (IV) - - détecteur de séquence, Code gris dans le domaine de l'horloge croisée, opération de ping - pong, réduction de la perte statique et dynamique, err
- Exchange two values without introducing the third variable
- Convert multiple pictures into one NPY file storage
猜你喜欢

MMEditing中超分模型训练与测试

Differences between FindIndex and indexof

UEFI查找PCI设备

Why is it that the live video of the devices connected to easygbs suddenly cannot be played? Insufficient database read / write

About the principle and code implementation of Siou (review IOU, giou, Diou, CIO)

Warning: Each child in a list should have a unique “key“ prop.

FPGA面试题目笔记(一)——FPGA开发流程、亚稳态和竞争冒险、建立保持时间、异步FIFO深度等
![Chapter 2 of machine learning [series] logistic regression model](/img/8f/b4c302c0309f5c91c7a40e682f9269.jpg)
Chapter 2 of machine learning [series] logistic regression model

Why don't we have our own programming language?

break,continue有什么区别和用法?
随机推荐
Chapter 2 of machine learning [series] logistic regression model
Why is it that the live video of the devices connected to easygbs suddenly cannot be played? Insufficient database read / write
Shandong University machine learning final 2021
021-MongoDB数据库从入门到放弃
Verilog realizes binocular camera image data acquisition and Modelsim simulation, and finally matlab performs image display
Text overflow failure
箭头函数的this指向
FPGA面试题目笔记(四)—— 序列检测器、跨时钟域中的格雷码、乒乓操作、降低静动态损耗、定点化无损误差、恢复时间和移除时间
2021-03-25
Vulnhub's breach1.0 range exercise
autojs,读取一行删除一行,停止自己外的脚本
数组去重。。。。
022 basic introduction to redis database 0
Differences between FindIndex and indexof
QT socket设置连接超时时间
FPGA interview notes (II) -- synchronous asynchronous D flip-flop, static and dynamic timing analysis, frequency division design, retiming
Using Metasploit Trojan horse for remote control
Chapter 6 of machine learning [series] random forest model
统计某次操作(函数)耗时时长
Shandong University machine learning experiment 7 pca+ SVM face recognition