当前位置:网站首页>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);}}
边栏推荐
- Pisanix v0.2.0 released | Added support for dynamic read-write separation
- Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
- 【OpenCV 图像处理2】:OpenCV 基础知识
- 22-07-31周总结
- Error: Not a signal or slot declaration
- Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium
- Solve connect: The requested address is not valid in its context
- LeetCode uses the minimum cost to climb the stairs----dp problem
- mysql没法Execute 大拿们求解
- 1667. 修复表中的名字
猜你喜欢
从零到一快速学会三子棋
02 【开发服务器 资源模块】
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
[ROS] (10) ROS Communication - Service Communication
数据增强Mixup原理与代码解读
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
nodeJs--封装路由
Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
DAY23:命令执行&代码执行漏洞
The 2022 EdgeX China Challenge will be grandly opened on August 3
随机推荐
Access Characteristics of Constructor under Inheritance Relationship
Matlab drawing 3
Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit
RAID disk array
【LeetCode刷题】-数之和专题(待补充更多题目)
学习笔记-----左偏树
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
Error: Not a signal or slot declaration
nodeJs--封装路由
后期学习计划
QT:神奇QVarient
post-study program
View handler stepping record
mysql没法Execute 大拿们求解
[ROS](10)ROS通信 —— 服务(Service)通信
树表的查找
Data to enhance Mixup principle and code reading
select tag custom style
Opening - Open a new .NET modern application development experience
协作D2D局部模型聚合的半分散联合学习