当前位置:网站首页>leetcode-对称二叉树
leetcode-对称二叉树
2022-08-05 02:00:00 【qq_52025208】
题目描述:
给定一个二叉树,检查它是否是镜像对称的。
例如,二叉树 [1,2,2,3,4,4,3] 是对称的。
1
/
2 2
/ \ /
3 4 4 3
class Solution {
public boolean isSymmetric(TreeNode root) {
if(root == null) return true;
return isSymmetricChild(root.left,root.right);
}
public boolean isSymmetricChild(TreeNode s,TreeNode t) {
if(s == null && t == null) return true;
if(s== null && t != null || s != null && t == null) return false;
if(s.val != t.val) return false;
return isSymmetricChild(s.left,t.right)&&isSymmetricChild(s.right,t.left);
}
}
边栏推荐
- ".NET IoT from scratch" series
- CPDA|运营人如何从负基础学会数据分析(SQL)
- 关于#sql shell#的问题,如何解决?
- Opencv - video frame skipping processing
- 如何创建rpm包
- pytorch的使用:使用神经网络进行气温预测
- 浅谈数据安全治理与隐私计算
- 深度学习原理学习小结 - Self-Attention/Transformer
- Log an error encountered when compiling google gn "I could not find a ".gn" file ..."
- The difference between a process in user mode and kernel mode [exclusive analysis]
猜你喜欢

Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design

Use of pytorch: Convolutional Neural Network Module

Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation

A new technical director, who calls DDD a senior, is convinced

Transfer Learning - Distant Domain Transfer Learning

编译预处理等细节

深度学习原理学习小结 - Self-Attention/Transformer

Xunrui cms website cannot be displayed normally after relocation and server change

IJCAI2022 | DictBert:采用对比学习的字典描述知识增强的预训练语言模型

Leetcode brushing questions - 22. Bracket generation
随机推荐
Exercise: Selecting a Structure (1)
【Word】Word公式导出PDF后出现井号括号#()错误
Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design
A new technical director, who calls DDD a senior, is convinced
意识形态的机制
MySQL学习
1349. Maximum number of students taking the exam Status Compression
[parameters of PyQT5 binding functions]
Chapter 09 Use of Performance Analysis Tools [2. Index and Tuning] [MySQL Advanced]
手把手基于YOLOv5定制实现FacePose之《YOLO结构解读、YOLO数据格式转换、YOLO过程修改》
Jincang database KingbaseES V8 GIS data migration solution (3. Data migration based on ArcGIS platform to KES)
进程在用户态和内核态的区别[独家解析]
【存储】曙光存储DS800-G35 ISCSI各映射LUN给服务器
如何基于OpenVINO POT工具简单实现对模型的量化压缩
Method Overriding and Object Class
AI+PROTAC|dx/tx完成500万美元种子轮融资
如何模拟后台API调用场景,很细!
Transfer Learning - Distant Domain Transfer Learning
重新审视分布式系统:永远不会有完美的一致性方案……
网络安全与元宇宙:找出薄弱环节