617. Merge Two Binary Trees; Difficulty:Easy

战国BC472年世界历史地图矢量文件SHP格式.zip 本资源为《战国BC472年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.26 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.

You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of new tree.

Example 1:
Input:
Tree 1 Tree 2
1 2
/ \ / \
3 2 1 3
/ \ \
5 4 7
Output:
Merged tree:
3
/ \
4 5
/ \ \
5 4 7

Note: The merging process must start from the root nodes of both trees.

算法分析:运用递归,两棵树同时先序遍历。(1)当t1为空,t2不空的时候,就把t2节点放回到t1的父结点;(2)当t1不空,t2空,那么原封不动,直接返回t1结点;(3)当t1和t2都不为空时,把t2的值加到t1,然后返回t1。最后返回的时t1树的根节点。

C语言版

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
struct TreeNode* mergeTrees(struct TreeNode* t1, struct TreeNode* t2) {
    if(t1 && t2)
    {
        t1->val += t2->val;
        t1->left = mergeTrees(t1->left, t2->left);
        t1->right = mergeTrees(t1->right, t2->right);
    }
    else if(t2)
        return t2;

    return t1;
}

Python版

# Definition for a binary tree node.
# class TreeNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution(object):
    def mergeTrees(self, t1, t2):
        """
        :type t1: TreeNode
        :type t2: TreeNode
        :rtype: TreeNode
        """
        if(t1 and t2):
            t1.val += t2.val
            t1.left = self.mergeTrees(t1.left, t2.left)
            t1.right = self.mergeTrees(t1.right, t2.right)
        elif(t2):
            return t2;
        return t1
西汉BC106年世界历史地图矢量文件SHP格式.zip 本资源为《西汉BC106年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.32 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

相关推荐

F500A 立式机触摸屏程序

F500A 立式机触摸屏程序

476. Number Complement 难度:简单

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: 1. The given integer is guaranteed to fit within the range of a 3

Vampirelzl的博客 663

地方科技局搭建区域性科技成果转化公共服务平台,哪家机构提供的数智化方案更成熟?.docx

科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。

561. Array Partition I; Difficulty : Easy

Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possibl

Vampirelzl的博客 504

汉语言文学22班 马旭 1243022203 现当代文学读书笔记.pdf

img_to_pdf_1796121273101.pdf

有了网段为什么还要有VLAN???

近几日,在学习VLAN及VXLAN方面的知识,对于产生原因做一个总结及详解。 VLAN(Virtual Local Area Network,虚拟局域网),其主要用途是用来缩小广播域,即进行隔离。 先对广播域的一个概念做如下描绘:如下图,主机A、B、C、D均连接在交换机SW1上,其中A、C同网段为192.168.252网段,而B和D同网段,为192.168.250网段。 现,假如A与C第...

dandandean_96的博客 6894

557. Reverse Words in a String III 难度:简单

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contest" Output

Vampirelzl的博客 462

[Linux]双网卡 CentOS 系统中指定网络请求走特定网卡的配置方法

本文详细介绍了在双网卡CentOS系统中指定特定域名/IP通过指定网卡传输流量的方法。核心步骤包括:1)确认网卡信息(ip addr)和域名IP解析(nslookup);2)添加临时路由(ip route add);3)持久化配置(创建route-eth1文件);4)验证配置(ip route show和curl测试)。文章还提供了网关查询、路由删除等常见问题的解决方法,并区分了不同CentOS版本重启网络服务的命令差异。通过合理配置路由规则,可实现流量的定向传输需求。

wingaso的博客 1586

540. Single Element in a Sorted Array Difficulty:Medium

Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once.Example 1:Input: [1,1,2,3,3

Vampirelzl的博客 433

SAP 接口测试操作-业务顾问

业务顾问测试接口操作

weixin_43657667的博客 5183

1.47寸ST7789V3彩屏硬件设计与驱动调试指南

TFT LCD是一种基于薄膜晶体管阵列控制像素明暗的主动式显示技术,其核心依赖于专用驱动IC(如ST7789V3)完成时序生成、GRAM管理与伽马校正。该类小尺寸彩色显示屏广泛应用于嵌入式HMI、IoT终端与可穿戴设备,具备高PPI、低功耗和SPI接口易集成等工程优势。理解RGB565数据格式、SPI Mode 0通信时序及关键寄存器(如0x36方向控制、0x3A像素格式、0x2A/0x2B地址窗口)是实现稳定显示的基础;而正确处理电源设计(严禁5V直供)、复位时序与背光PWM调光,则直接决定系统可靠性与能

weixin_30995917的博客 175

Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.算法解析:既可以用深度优先搜索,也可以用广度优先搜索,前者可以节省代码,后者可以提高速

Vampirelzl的博客 379

VS2017配置PCL1.9.1 for win10(超详细)

准备工作 VS2017 自行下载 PCL1.9.1 点击链接跳转Github下载,根据自己的环境选择 win64或win32,作者下载的是:PCL-1.9.1-AllInOne-msvc2017-win64.exepcl-1.9.1-pdb-msvc2017-win64.zip 安装PCL 双击点开PCL-1.9.1-AllInOne-msvc2017-win64.exe,选择Add PCL to the system PATH for all users, 更改安装路径,E:\Progra

malapoa的博客 1152

657. Judge Route Circle-Difficulty:Easy

Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The move sequence is represented by a

Vampirelzl的博客 366

手把手教你学simulink(41.4)--逆变器电场景示例:基于Simulink的主从控制的多逆变器协同控制(Multi-Inverter Coordinated Control)

需求分析在现代电力系统中,分布式发电和储能系统的广泛应用使得多个逆变器并联运行成为常见的应用场景。为了确保多个逆变器之间的协同工作,实现系统的稳定性和高效性,通常采用主从控制(Master-Slave Control)策略。主从控制通过一个主控制器(Master)来协调多个从控制器(Slave),确保所有逆变器的输出电压、频率和功率分配符合预期目标。本项目将基于Simulink平台,开发一个多逆变器协同控制系统,采用主从控制策略,实现对多个逆变器的精确控制和优化。

MHD0815的博客 309

uniapp - 实现集成调用zebra斑马打印机+打印标签+打印二维码详细实例代码,通过蓝牙连接打印机打印与通过打印机IP和端口两种方式适配斑马打印机(全平台兼容H5、微信小程序、苹果安卓App)

uniapp适配斑马打印机 实现标签打印,uniapp适配斑马打印机实现标签打印,uniapp调用zebra斑马打印机打印标签,uniApp连接传统蓝牙的斑马打印机打印,实现标签打印功能uniapp 蓝牙连接斑马打印机发送zpl指令打印,适配斑马(Zebra)牌打印机,小程序调用蓝牙打印机完整代码,uniapp 打印机wifi链接 蓝牙链接,uniapp斑马打印机,实现二维码标签展示以及打印,APP端连接打印机打印小票和标签,uniapp使用斑马打印中文不出来,打印机连接不上,打印没反应怎么办,打印报错,斑

🏆 前端领域优质创作者 1万+

442. Find All Duplicates in an Array Difficulty : Medium

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space

Vampirelzl的博客 358

第3.1.3章 机器人第三方库实战总结:ROS 2 入门实战及和ROS1的对比,打通机器人开发的任督二脉

本文针对机器人SLAM开发中第三方库的学习痛点,重点介绍ROS 2在SLAM中的应用。文章首先对比ROS 1与ROS 2的核心差异,梳理ROS 2知识图谱,包括节点、话题、服务等核心概念。通过实战项目演示如何构建激光SLAM节点,结合代码详解运行流程。最后给出学习建议,强调动手实践的重要性,帮助开发者快速掌握ROS 2在SLAM开发中的关键应用。

行知SLAM 189

695. Max Area of Island Difficulty: Easy

Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surroun

Vampirelzl的博客 355

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

566. Reshape the Matrix Difficult : Easy

In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data.You’re given a matrix represented by a two-dimensio

Vampirelzl的博客 352

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

515. Find Largest Value in Each Tree Row Difficulty: Medium

You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]算法分析:考查BFS,或者说是树的层序遍历,但要注意区分每一层。我

Vampirelzl的博客 333

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

500. Keyboard Row 难度:简单

Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below.Example 1:Input: ["Hello", "Alaska", "Dad", "Peace"] Outp

Vampirelzl的博客 333

526. Beautiful Arrangement Difficulty: Medium

Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <

Vampirelzl的博客 314

647. Palindromic Substrings Difficulty: Medium

Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consist of

Vampirelzl的博客 314

226. Invert Binary Tree Difficult: Easy

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1算法分析:可以用层序遍历的方法交换左右子树,也可以直接递归。C语言版struct TreeNode* invertTree(struct TreeNode* roo

Vampirelzl的博客 307
上一篇: 657. Judge Route Circle-Difficulty:Easy
下一篇: 561. Array Partition I; Difficulty : Easy
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值