当前位置:网站首页>剑指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);
}
}
边栏推荐
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
- anaconda安装第三方包
- 第3章:类的加载过程(类的生命周期)详解
- 十二、启动流程
- Assembly and interface technology experiment 5-8259 interrupt experiment
- Attack and defense world ditf Misc
- 基於 QEMUv8 搭建 OP-TEE 開發環境
- Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
- Adjustable DC power supply based on LM317
- Unity3d Learning Notes 6 - GPU instantiation (1)
猜你喜欢

Web APIs DOM 时间对象

signed、unsigned关键字

CCNA Cisco network EIGRP protocol

Management background --4, delete classification

MySQL数据库基本操作-DML

Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"

Powerful domestic API management tool

Adjustable DC power supply based on LM317

PVL EDI project case

The nearest common ancestor of binary (search) tree ●●
随机推荐
【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真
pytorch_YOLOX剪枝【附代码】
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
[10:00 public class]: basis and practice of video quality evaluation
微信红包封面小程序源码-后台独立版-带测评积分功能源码
volatile关键字
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
Attack and defense world ditf Misc
MySQL数据库基本操作-DML
Attack and defense world miscall
C # realizes crystal report binding data and printing 4-bar code
Assembly and Interface Technology Experiment 6 - ADDA conversion experiment, AD acquisition system in interrupt mode
【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
GD32F4XX串口接收中断和闲时中断配置
Notes de développement du matériel (10): flux de base du développement du matériel, fabrication d'un module USB à RS232 (9): création de la Bibliothèque d'emballage ch340g / max232 SOP - 16 et Associa
图像的spatial domain 和 frequency domain 图像压缩
HDR image reconstruction from a single exposure using deep CNNs阅读札记