当前位置:网站首页>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
边栏推荐
- Function executes only the once function for the first time
- 聯想拯救者Y9000X 2020
- leetcode--977. Squares of a Sorted Array
- Atcoder beginer contest 248c dice sum (generating function)
- freeCodeCamp----time_ Calculator exercise
- YARN线上动态资源调优
- Reading notes: fedgnn: Federated graph neural network for privacy preserving recommendation
- RAC environment alert log error drop transient type: systp2jw0acnaurdgu1sbqmbryw = = troubleshooting
- Oracle and MySQL batch query all table names and table name comments under users
- JS 烧脑面试题大赏
猜你喜欢
随机推荐
China creates vast research infrastructure to support ambitious climate goals
Decentralized Collaborative Learning Framework for Next POI Recommendation
Ora-600 encountered in Oracle environment [qkacon: fjswrwo]
Apache Atlas Compilation and installation records
Oracle view related
神经元与神经网络
MySQL [read / write lock + table lock + row lock + mvcc]
Express②(路由)
MySQL and PgSQL time related operations
UML Unified Modeling Language
Oracle clear SQL cache
AtCoder Beginner Contest 248C Dice Sum (生成函数)
Static interface method calls are not supported at language level '5'
Basic SQL query and learning
Ora-16047 of a DG environment: dgid mismatch between destination setting and target database troubleshooting and listening vncr features
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
大专的我,闭关苦学 56 天,含泪拿下阿里 offer,五轮面试,六个小时灵魂拷问
商家案例 | 运动健康APP用户促活怎么做?做好这几点足矣
Jiannanchun understood the word game
Choreographer全解析