当前位置:网站首页>剑指offer刷题记录1
剑指offer刷题记录1
2022-07-06 14:45:00 【马孔多镇长】
剑指offer刷题记录
101. 对称二叉树
️ 给你一个二叉树的根节点 root
, 检查它是否轴对称
️ 示例1:
输入:root = [1,2,2,3,4,4,3] 输出:true
️ 示例2:
输入:root = [1,2,2,null,3,null,3] 输出:false
️ 提示:
树中节点数目在范围
[1, 1000]
内-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);
}
}
边栏推荐
- OpenCV VideoCapture. Get() parameter details
- pytorch_YOLOX剪枝【附代码】
- GPS from getting started to giving up (12), Doppler constant speed
- A Mexican airliner bound for the United States was struck by lightning after taking off and then returned safely
- HDU 4912 paths on the tree (lca+)
- Data storage (1)
- SQL Server生成自增序号
- Inno Setup 打包及签名指南
- 自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
- PVL EDI project case
猜你喜欢
Powerful domestic API management tool
0 basic learning C language - interrupt
Mise en place d'un environnement de développement OP - tee basé sur qemuv8
signed、unsigned关键字
Xiaoman network model & http1-http2 & browser cache
LeetCode 练习——剑指 Offer 26. 树的子结构
Management background --4, delete classification
Leetcode question brushing (XI) -- sequential questions brushing 51 to 55
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
labelimg的安装与使用
随机推荐
0 basic learning C language - digital tube
插入排序与希尔排序
Four data streams of grpc
Chapter 4: talk about class loader again
空结构体多大?
i.mx6ull搭建boa服务器详解及其中遇到的一些问题
做接口测试都测什么?有哪些通用测试点?
[10:00 public class]: basis and practice of video quality evaluation
How do I write Flask's excellent debug log message to a file in production?
小常识:保险中的“保全”是什么?
Search element topic (DFS)
[leetcode daily clock in] 1020 Number of enclaves
Assembly and interface technology experiment 5-8259 interrupt experiment
[sciter]: encapsulate the notification bar component based on sciter
图像的spatial domain 和 frequency domain 图像压缩
基於 QEMUv8 搭建 OP-TEE 開發環境
MySQL约束的分类、作用及用法
Solve project cross domain problems
[sciter bug] multi line hiding
Management background --2 Classification list