当前位置:网站首页>剑指 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);
}
};
边栏推荐
- Message subscription and publishing
- [clean up the extraordinary image of Disk C]
- Canvas utility library fabric JS user manual
- Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
- Qt学习21 Qt 中的标准对话框(下)
- “又土又穷”的草根高校,凭什么被称为“东北小清华”?
- JVM family - overview, program counter day1-1
- JS Part III
- Global event bus
- Leetcode(4)——尋找兩個正序數組的中比特數
猜你喜欢
[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)"/>
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
Exercise 10-6 recursively find Fabonacci sequence
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Generate directories from web content
Exercise 8-7 string sorting
Qt学习21 Qt 中的标准对话框(下)
Use vscode to view hex or UTF-8 codes
Spring cup eight school league
Qt学习17 对话框及其类型
[email protected])"/>
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
随机推荐
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.)
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
Qt学习17 对话框及其类型
Uniapp skills - dom display and hiding
7-10 calculate salary
Rasp implementation of PHP
消息订阅与发布
selenium 浏览器(1)
Qt学习20 Qt 中的标准对话框(中)
Back to top implementation
[Jilin University] information sharing of postgraduate entrance examination and re examination
JS matrix zero
Qt学习18 登录对话框实例分析
核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)
Understanding of closures
Uniapp tips - scrolling components
QT learning 21 standard dialog box in QT (Part 2)
[acnoi2022] guess numbers
Exercise 7-6 count capital consonants
Too many files with unapproved license