当前位置:网站首页>力扣刷题 101. 对称二叉树
力扣刷题 101. 对称二叉树
2022-04-23 13:54:00 【Candy_Rainbow_】
var isSymmetric = function(root) {
const isTrue = (left, right) => {//左右子树是不是镜像
if(left == null && right == null)return true;//走到了根节点
if(left == null || right == null)return false;//左右子树有一个不空
if(left.val != right.val)return false;//对称点相等不相等
return isTrue(left.left, right.right) && isTrue(left.right, right.left);//子问题
}
if(root == null)return true;
return isTrue(root.left, root.right);
};
版权声明
本文为[Candy_Rainbow_]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Candy_Rainbow_/article/details/124350738
边栏推荐
- leetcode--357. 统计各位数字都不同的数字个数
- [VMware] address of VMware Tools
- Leetcode brush question 897 incremental sequential search tree
- 美联储数字货币最新进展
- Database transactions
- Oracle generates millisecond timestamps
- Postman reference summary
- Detailed explanation of Oracle tablespace table partition and query method of Oracle table partition
- MySQL and PgSQL time related operations
- Lenovo Saver y9000x 2020
猜你喜欢
[VMware] address of VMware Tools
What is the difference between blue-green publishing, rolling publishing and gray publishing?
零拷貝技術
Express middleware ③ (custom Middleware)
[machine learning] Note 4. KNN + cross validation
MySQL [read / write lock + table lock + row lock + mvcc]
Dynamic subset division problem
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
SQL learning | set operation
Apache seatunnel 2.1.0 deployment and stepping on the pit
随机推荐
try --finally
Tensorflow Download
About me
Dolphin scheduler integrates Flink task pit records
elmo(BiLSTM-CRF+elmo)(Conll-2003 命名实体识别NER)
Parameter comparison of several e-book readers
专题测试05·二重积分【李艳芳全程班】
Window function row commonly used for fusion and de duplication_ number
Android interview theme collection
Small case of web login (including verification code login)
SQL learning window function
The difference between is and as in Oracle stored procedure
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough
蓝绿发布、滚动发布、灰度发布,有什么区别?
Get the attribute value difference between two different objects with reflection and annotation
自动化的艺术
leetcode--380.O(1) 时间插入、删除和获取随机元素
UNIX final exam summary -- for direct Department
Generate 32-bit UUID in Oracle