当前位置:网站首页>剑指 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垃圾回收机
- Learn to punch in today
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- Collection of mobile adaptation related articles
- 叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
- JS download files through URL links
- Similarities and differences of sessionstorage, localstorage and cookies
- C language,%d% Difference between 2D%2d%02d
- QT learning 19 standard dialog box in QT (top)
- JS shift operators (< <,> > and > > >)
猜你喜欢

Implementation of Muduo asynchronous logging

【吉林大学】考研初试复试资料分享
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂

Rasp implementation of PHP

小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。

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

MySQL data processing value addition, deletion and modification

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

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

Spring cup eight school league
随机推荐
Canvas utility library fabric JS user manual
Exercise 10-1 judge the three digits that meet the conditions
RocksDB LRUCache
Exercise 8-7 string sorting
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
7-8 overspeed judgment
JS new challenges
虽然不一定最优秀,但一定是最努力的!
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
[ACNOI2022]猜数
Spring cup eight school league
战略、战术(和 OKR)
jvm-类加载
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
JS shift operators (< <,> > and > > >)
JS get DPI, PX to cm, cm to PX
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
[combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
Qt学习20 Qt 中的标准对话框(中)
Exercise 8-8 moving letters