当前位置:网站首页>2022.7.15-----leetcode. five hundred and fifty-eight
2022.7.15-----leetcode. five hundred and fifty-eight
2022-07-18 22:42:00 【Lu 727】
public Node intersect(Node quadTree1, Node quadTree2) {
// When at least 1 When one is a leaf
if (quadTree1.isLeaf) {
if (quadTree1.val) // When a tree is 1 leaf , This node must be 1 leaf
return new Node(true, true);
else// if 0 leaf , This node is the same as another tree node
return new Node(quadTree2.val, quadTree2.isLeaf,
quadTree2.topLeft, quadTree2.topRight, quadTree2.bottomLeft, quadTree2.bottomRight);
}
if (quadTree2.isLeaf) {
return intersect(quadTree2, quadTree1);// Inversion order
}
// The nodes of both trees are not leaves
Node o1 = intersect(quadTree1.topLeft, quadTree2.topLeft);
Node o2 = intersect(quadTree1.topRight, quadTree2.topRight);
Node o3 = intersect(quadTree1.bottomLeft, quadTree2.bottomLeft);
Node o4 = intersect(quadTree1.bottomRight, quadTree2.bottomRight);
// When the child nodes are all leaves with the same value , This node is a leaf
if (o1.isLeaf && o2.isLeaf && o3.isLeaf && o4.isLeaf &&
o1.val == o2.val && o1.val == o3.val && o1.val == o4.val) {
return new Node(o1.val, true);
}else// Otherwise, the node is not a leaf
return new Node(false, false, o1, o2, o3, o4);
}边栏推荐
- A New Optimizer Using Particle Swarm Theory
- How to record sound on win11 screen? Win11 method of recording screen video with sound
- 语音转换主要涉及技术记录
- Sff1602-mhchxm ultrafast recovery diode sff1602
- Leetcode48. rotate image
- Deep understanding of C language pointer and array
- The distant savior obeys the objective law (V) -- cultural attribute
- 博途PLC模糊PID控制(量化因子和比例因子)
- 活动回顾 | 与MindSpore深度畅聊:开源如何探索AI领域全场景
- The distant savior obeys the objective law (VI) -- cultural attribute
猜你喜欢

Problem solving -- > online OJ (16)

Honghu Wanlian Zhiyuan development board is officially integrated into the openharmony backbone

【部署】Redis

数据受限条件下的多模态处理技术综述

1. Create prism project

Three sides of headlines + four sides of Alibaba + five sides of Tencent took the offer to share the summary, and finally joined Alibaba
![[UCOS III source code analysis] - Software Timer](/img/af/84b1bb47211668b0eb516ccf65b393.png)
[UCOS III source code analysis] - Software Timer

Accessing local variables in anonymous inner classes

KDD 2017 | metapath2vec: scalable representation learning of heterogeneous graphs

在匿名内部类中访问局部变量
随机推荐
Enjoy meta mode of creation mode
Visual Studio 生产环境配置方案:SlowCheetah
技术干货| MindSpore新一代自主研发分子模拟库:Mind-Sponge
除了长安,这四个国产品牌也用“雷克萨斯脸”,中国设计倒退了?
Open source ten questions, a quick start guide for community newcomers
7月7日易用性SIG技术分享活动精彩回顾
[deployment] redis
大疆校招测评题--循环赛问题
PHP 内存溢出 ?如何解决呢 ?
A New Optimizer Using Particle Swarm Theory
Developers share | handwriting operator is not so difficult. I'll teach you to use mindspire to realize adaptive average pooling operator!
JS Huawei od log time sorting
5g NR notes
Standard input / output stream
修改服务器密码
Developers share the initial experience of tinyms, a high-level API tool of mindspire!
Tencent is all around. It's silly to ask
博途PLC模糊PID控制(量化因子和比例因子)
The distant savior obeys the objective law (VII) -- cultural attribute
华为od js 日志排序