当前位置:网站首页>Force deduction brush question 101 Symmetric binary tree
Force deduction brush question 101 Symmetric binary tree
2022-04-23 13:56:00 【Candy_ Rainbow_】
var isSymmetric = function(root) {
const isTrue = (left, right) => {// Whether the left and right subtrees are mirror images
if(left == null && right == null)return true;// Went to the root node
if(left == null || right == null)return false;// One of the left and right subtrees is not empty
if(left.val != right.val)return false;// The points of symmetry are equal but not equal
return isTrue(left.left, right.right) && isTrue(left.right, right.left);// Sub problem
}
if(root == null)return true;
return isTrue(root.left, root.right);
};
版权声明
本文为[Candy_ Rainbow_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231353588847.html
边栏推荐
- 2022年江西最新建筑八大员(质量员)模拟考试题库及答案解析
- About note 1
- Express ② (routing)
- crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
- 专题测试05·二重积分【李艳芳全程班】
- AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
- AtomicIntegerArray源码分析与感悟
- Dolphin scheduler integrates Flink task pit records
- PG library to view the distribution keys of a table in a certain mode
- Two ways to deal with conflicting data in MySQL and PG Libraries
猜你喜欢

MySQL and PgSQL time related operations

Handling of high usage of Oracle undo

SSM project deployed in Alibaba cloud

Information: 2021 / 9 / 29 10:01 - build completed with 1 error and 0 warnings in 11S 30ms error exception handling

【vmware】vmware tools 地址

自动化的艺术

专题测试05·二重积分【李艳芳全程班】

10g database cannot be started when using large memory host

Apache Atlas Compilation and installation records

freeCodeCamp----time_ Calculator exercise
随机推荐
Express middleware ③ (custom Middleware)
The query did not generate a result set exception resolution when the dolphin scheduler schedules the SQL task to create a table
低频量化之明日涨停预测
Android篇:2019初中级Android开发社招面试解答(中
Detailed explanation of redis (Basic + data type + transaction + persistence + publish and subscribe + master-slave replication + sentinel + cache penetration, breakdown and avalanche)
Generate 32-bit UUID in Oracle
PG library checks the name
3300万IOPS、39微秒延迟、碳足迹认证,谁在认真搞事情?
Function executes only the once function for the first time
Express②(路由)
Oracle view related
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
UML统一建模语言
Oracle defines self incrementing primary keys through triggers and sequences, and sets a scheduled task to insert a piece of data into the target table every second
Window analysis function last_ VALUE,FIRST_ VALUE,lag,lead
Test the time required for Oracle library to create an index with 7 million data in a common way
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
UNIX final exam summary -- for direct Department
Apache seatunnel 2.1.0 deployment and stepping on the pit
cnpm的诡异bug