当前位置:网站首页>剑指 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);
}
};
边栏推荐
- Onmenusharetimeline custom shared content is invalid, and the title and icon are not displayed
- Uniapp skills - scrolling components -1
- Why don't I have a rookie medal
- Spring cup eight school league
- JS get DPI, PX to cm, cm to PX
- QT learning 23 layout manager (II)
- QT learning 17 dialog box and its types
- Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
- UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
- Exercise 9-3 plane vector addition
猜你喜欢
protobuf与grpc
牛客网:过河卒
Generate directories from web content
Qt学习17 对话框及其类型
[Jilin University] information sharing of postgraduate entrance examination and re examination
Installation impression notes
jvm-类加载
Qt学习22 布局管理器(一)
Leetcode(4)——尋找兩個正序數組的中比特數
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
随机推荐
Learn to punch in today
protobuf与grpc
信创产业现状、分析与预测
Too many files with unapproved license
Solve the problem of dormitory router campus network sharing login
Article content typesetting and code highlighting
RocksDB LRUCache
Vite project commissioning
6-9 statistics of single digits (15 points)
The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
JS download files through URL links
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
Redis:字符串类型数据的操作命令
全局事件总线
MySQL data processing value addition, deletion and modification
虽然不一定最优秀,但一定是最努力的!
Example analysis of QT learning 18 login dialog box
Qt学习19 Qt 中的标准对话框(上)
Qt学习21 Qt 中的标准对话框(下)
Multi person collaborative data annotation based on Baidu brain easydata from scratch