当前位置:网站首页>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);}}边栏推荐
- C语言日记 9 if的3种语句
- Industry case | insurance companies of the world's top 500 construction standards can be used to drive the business analysis system
- select tag custom style
- HDU 1114:Piggy-Bank ← 完全背包问题
- DAY22: sqli-labs shooting range clearance wp (Less01~~Less20)
- C language diary 9 3 kinds of statements of if
- DAY22:sqli-labs 靶场通关wp(Less01~~Less20)
- shell语句修改txt文件或者sh文件
- ARM Mailbox
- QT:神奇QVarient
猜你喜欢

Matlab map with color representation module value size arrow

leetcode 15

nodeJs--encapsulate routing

VSCode Change Default Terminal 如何修改vscode的默认terminal

使用SuperMap iDesktopX数据迁移工具迁移ArcGIS数据

Matlab画图3

Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中

Regular expression to match a certain string in the middle

从零到一快速学会三子棋

The design idea of DMicro, the Go microservice development framework
随机推荐
leetcode-另一棵树的子树
回顾51单片机
leetcode-对称二叉树
Access Characteristics of Constructor under Inheritance Relationship
SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
行业案例|世界 500 强险企如何建设指标驱动的经营分析系统
Industry case | insurance companies of the world's top 500 construction standards can be used to drive the business analysis system
torch.roll()
开源协议说明LGPL
Matlab map with color representation module value size arrow
1873. The special bonus calculation
The 2022 EdgeX China Challenge will be grandly opened on August 3
继承关系下构造方法的访问特点
C language implements a simple number guessing game
Matlab画图3
Review 51 MCU
Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
lua learning
[In-depth study of 4G/5G/6G topic-51]: URLLC-16-"3GPP URLLC related protocols, specifications, and technical principles in-depth interpretation"-11-High reliability technology-2-Link adaptive enhancem
[Decryption] Can the NFTs created by OpenSea for free appear in my wallet without being chained?