当前位置:网站首页>Sword finger offer question brushing record 1
Sword finger offer question brushing record 1
2022-07-06 22:30:00 【Mayor of Macondo】
The finger of the sword offer Record of writing questions
101. Symmetric binary tree
️ Give you the root node of a binary tree root
, Check whether it is axisymmetric
️ Example 1:
Input :root = [1,2,2,3,4,4,3] Output :true
️ Example 2:
Input :root = [1,2,2,null,3,null,3] Output :false
️ Tips :
The number of nodes in the tree is in the range
[1, 1000]
Inside-100 <= Node.val <= 100
class Solution {
public boolean isSymmetric(TreeNode root) {
if(root==null){
return true;
}
return isMirror(root,root);
}
boolean isMirror(TreeNode r1,TreeNode r2){
if(r1==null&&r2==null){
return true;
}
if(r1==null||r2==null){
return false;
}
return (r1.val==r2.val)&&isMirror(r1.left,r2.right)&&isMirror(r1.right,r2.left);
}
}
边栏推荐
- 【LeetCode】19、 删除链表的倒数第 N 个结点
- Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
- 2022-07-05 stonedb sub query processing parsing time analysis
- MySQL数据库基本操作-DML
- Classic sql50 questions
- 【编译原理】做了一半的LR(0)分析器
- UE4蓝图学习篇(四)--流程控制ForLoop和WhileLoop
- Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
- 在IPv6中 链路本地地址的优势
- NetXpert XG2帮您解决“布线安装与维护”难题
猜你喜欢
C# 三种方式实现Socket数据接收
Export MySQL table data in pure mode
Management background --2 Classification list
Aardio - 利用customPlus库+plus构造一个多按钮组件
Spatial domain and frequency domain image compression of images
Config:invalid signature solution and troubleshooting details
Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
Classic sql50 questions
Aardio - 封装库时批量处理属性与回调函数的方法
[leetcode] 19. Delete the penultimate node of the linked list
随机推荐
Classic sql50 questions
第4章:再谈类的加载器
China 1,4-cyclohexanedimethanol (CHDM) industry research and investment decision-making report (2022 Edition)
signed、unsigned关键字
What are the interface tests? What are the general test points?
Solve project cross domain problems
config:invalid signature 解决办法和问题排查详解
Gd32f4xx serial port receive interrupt and idle interrupt configuration
图像的spatial domain 和 frequency domain 图像压缩
Mysql database basic operations DML
Plafond du tutoriel MySQL, bien collecté, regardez lentement
OpenCV VideoCapture. Get() parameter details
Attack and defense world ditf Misc
Barcodex (ActiveX print control) v5.3.0.80 free version
Aardio - 通过变量名将变量值整合到一串文本中
Management background --3, modify classification
PVL EDI 项目案例
Config:invalid signature solution and troubleshooting details
枚举与#define 宏的区别
中国1,4-环己烷二甲醇(CHDM)行业调研与投资决策报告(2022版)