当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
详细全面的postman接口测试实战教程
Method Overriding and Object Class
关于#sql shell#的问题,如何解决?
Are testing jobs so hard to find?I am 32 this year and I have been unemployed for 2 months. What should an older test engineer do next to support his family?
【Unity入门计划】2D游戏中遮挡问题的处理方法&伪透视
(十七)51单片机——AD/DA转换
第十四天&postman
Exercise: Selecting a Structure (1)
汇编语言之源程序
Understand the recommendation system in one article: Recall 06: Two-tower model - model structure, training method, the recall model is a late fusion feature, and the sorting model is an early fusion
随机推荐
Exploding the circle of friends, Alibaba produced billion-level concurrent design quick notes are too fragrant
tcp中的三次握手与四次挥手
ExcelPatternTool: Excel表格-数据库互导工具
金仓数据库 KingbaseES V8 GIS数据迁移方案(3. 基于ArcGIS平台的数据迁移到KES)
The difference between a process in user mode and kernel mode [exclusive analysis]
Flink 1.15.1 集群搭建(StandaloneSession)
source program in assembly language
Greenplum数据库故障分析——版本升级后gpstart -a为何返回失败
KingbaseES V8 GIS data migration solution (2. Introduction to the capabilities of Kingbase GIS)
day14--postman interface test
直播回放含 PPT 下载|基于 Flink & DeepRec 构建 Online Deep Learning
Is DDOS attack really unsolvable?Do not!
Tree search (bintree)
sql语句多字段多个值如何进行排序
迅睿cms网站搬迁换了服务器后网站不能正常显示
使用SuperMap iDesktopX数据迁移工具迁移地图文档和符号
(十七)51单片机——AD/DA转换
一文看懂推荐系统:召回06:双塔模型——模型结构、训练方法,召回模型是后期融合特征,排序模型是前期融合特征
XMjs跨域问题解决
EBS利用虚拟列及hint 提示优化sql案例一则