当前位置:网站首页>剑指 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);
}
};
边栏推荐
- jvm-类加载
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- jvm-对象生命周期
- Exercise 8-2 calculate the sum and difference of two numbers
- Canvas utility library fabric JS user manual
- “又土又穷”的草根高校,凭什么被称为“东北小清华”?
- Current situation, analysis and prediction of information and innovation industry
- Redis: redis data structure and key operation commands
- 6-9 statistics of single digits (15 points)
- Spring cup eight school league
猜你喜欢

Spring cup eight school league

JS Part III
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线

protobuf与grpc

Qt学习20 Qt 中的标准对话框(中)

Exercise 6-6 use a function to output an integer in reverse order

Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides

How to use lxml to judge whether the website announcement is updated

消息订阅与发布
随机推荐
[combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
JS shift operators (< <,> > and > > >)
可编程逻辑器件软件测试
Qt学习18 登录对话框实例分析
好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
Leetcode(4)——寻找两个正序数组的中位数
Uniapp skills - dom display and hiding
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
Qt学习17 对话框及其类型
js . Find the first palindrome string in the array
牛客网:过河卒
Message subscription and publishing
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
Too many files with unapproved license
JVM object lifecycle
八大排序
Exercise 7-6 count capital consonants
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
jvm-类加载