当前位置:网站首页>Sword finger offer 28 Symmetric binary tree
Sword finger offer 28 Symmetric binary tree
2022-07-03 14:22:00 【anieoo】
Original link : The finger of the sword Offer 28. Symmetric binary tree
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);
}
};
边栏推荐
- fpga阻塞赋值和非阻塞赋值
- Canvas utility library fabric JS user manual
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- ZABBIX saves the page blank after adding calculated items
- Zabbix添加Calculated items后保存页面成空白
- 使用并行可微模拟加速策略学习
- 7-23 currency conversion (using array conversion)
- 556. 下一个更大元素 III
- Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
- 2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
猜你喜欢

JVM object lifecycle

常见问题之PHP——ldap_add(): Add: Undefined attribute type in

Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值

Redis: operation command of string type data

愉悦资本新双币基金近40亿元完成首次关账

Exercise 10-2 recursive factorial sum

Accelerating strategy learning using parallel differentiable simulation

7-18 finding the single root of polynomial by dichotomy

7-8 overspeed judgment

八大排序
随机推荐
7-28 monkeys choose King (Joseph problem)
js . Find the first palindrome string in the array
Exercise 10-2 recursive factorial sum
JVM垃圾回收机
Add ZABBIX calculation type itemcalculated items
一文了解微分段应用场景与实现机制
C library function - qsort()
Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
7-20 print 99 formula table (format output)
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
Why don't I have a rookie medal
Exercise 8-7 string sorting
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
全文检索引擎Solr系列—–全文检索基本原理
Exercise 10-6 recursively find Fabonacci sequence
String sort
JVM object lifecycle
Redis:字符串類型數據的操作命令
JS Part III
别再问自己适不适合做软件测试了