当前位置:网站首页>剑指 Offer 28. 对称的二叉树
剑指 Offer 28. 对称的二叉树
2022-07-03 13:43:00 【anieoo】
原题链接:剑指 Offer 28. 对称的二叉树
solution:
class Solution {
public:
bool isSymmetric(TreeNode* root) {
if(root == NULL) return true;
return dfs(root->left,root->right);
}
bool dfs(TreeNode *left, TreeNode *right) {
if(left == NULL && right == NULL) return true;
else if((left != NULL && right == NULL) || (left == NULL && right != NULL)) return false;
if(left->val != right->val) return false;
return dfs(left->left,right->right) && dfs(left->right, right->left);
}
};
边栏推荐
- Qt学习20 Qt 中的标准对话框(中)
- Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
- js 2023. String pair equal to the target string after connection
- Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
- Exercise 10-2 recursive factorial sum
- 可编程逻辑器件软件测试
- Exercise 10-8 recursive implementation of sequential output of integers
- Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)
- Configure stylelint
- 7-11 calculation of residential water charges by sections
猜你喜欢

Current situation, analysis and prediction of information and innovation industry

中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿

Comprehensive case of MySQL data addition, deletion, modification and query

Failure of vector insertion element iterator in STL

concat和concat_ws()区别及group_concat()和repeat()函数的使用

Qt学习17 对话框及其类型

Exercise 10-2 recursive factorial sum

Exercise 10-6 recursively find Fabonacci sequence

TS code automatically generates JS

JVM object lifecycle
随机推荐
Installation impression notes
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
QT learning 23 layout manager (II)
Understanding of closures
中国锂电池电解液行业市场专项调研报告(2022版)
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
Uniapp skills - dom display and hiding
Collection of mobile adaptation related articles
Qt学习18 登录对话框实例分析
JVM class loading
战略、战术(和 OKR)
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
QT learning 25 layout manager (4)
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
Qt学习19 Qt 中的标准对话框(上)
Analysis of the characteristics of page owner
虽然不一定最优秀,但一定是最努力的!
6-9 statistics of single digits (15 points)
Qt学习21 Qt 中的标准对话框(下)
3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)