当前位置:网站首页>leetcode - symmetric binary tree
leetcode - symmetric binary tree
2022-08-05 02:43:00 【qq_52025208】
Title description:
Given a binary tree, check if it is mirror-symmetric.
For example, the binary tree [1,2,2,3,4,4,3] is symmetric.
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)span>;}public boolean isSymmetricChild(TreeNode s,TreeNode t) {if(s == null && t == nullspan>) 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)span>&&isSymmetricChild(s.right,t.left);}}
边栏推荐
猜你喜欢
[Decryption] Can the NFTs created by OpenSea for free appear in my wallet without being chained?
【 2 】 OpenCV image processing: basic knowledge of OpenCV
常见的硬件延迟
Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
Regular expression to match a certain string in the middle
虚拟内存原理与技术
云原生(三十二) | Kubernetes篇之平台存储系统介绍
LeetCode uses the minimum cost to climb the stairs----dp problem
shell语句修改txt文件或者sh文件
OpenGL 工作原理
随机推荐
Pisanix v0.2.0 发布|新增动态读写分离支持
View handler 踩坑记录
ARM Mailbox
Using OpenVINO to implement the flying paddle version of the PGNet inference program
学习笔记-----左偏树
Intel XDC 2022 Wonderful Review: Build an Open Ecosystem and Unleash the Potential of "Infrastructure"
LeetCode uses the minimum cost to climb the stairs----dp problem
注意潍坊开具发票一般需要注意
leetcode-另一棵树的子树
View handler stepping record
VSCode Change Default Terminal how to modify the Default Terminal VSCode
mysql tree structure query problem
数据增强Mixup原理与代码解读
Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
1873. The special bonus calculation
Introduction to SDC
STM32使用stm32cubemx LL库系列教程
[Fortune-telling-60]: "The Soldier, the Tricky Way"-2-Interpretation of Sun Tzu's Art of War
C student management system head to add a student node
后期学习计划