【Leetcode 101.对称二叉树】【C语言】判断一颗二叉树是否是对称二叉树(相同的树的变形)

对称二叉树



代码

c 复制代码
bool isSametree(struct TreeNode*root1,struct TreeNode*root2)
{
   if(root1==NULL&&root2==NULL)
   return true;
   if(root1==NULL||root2==NULL)
   return false;
   if(root1->val!=root2->val)
   return false;
   return isSametree(root1->left,root2->right)
   &&isSametree(root1->right,root2->left);
}
bool isSymmetric(struct TreeNode* root) {
    return isSametree(root->left,root->right);
}
相关推荐
TracyCoder1236 分钟前
LeetCode Hot100(51/100)——155. 最小栈
数据结构·算法·leetcode
wu_asia11 分钟前
每日一练叁
算法
dalong1012 分钟前
A24:圈住小猫游戏
笔记·算法·游戏·aardio
Y.O.U..16 分钟前
力扣刷题-86.分隔链表
算法·leetcode·链表
Elastic 中国社区官方博客16 分钟前
从向量到关键词:在 LangChain 中的 Elasticsearch 混合搜索
大数据·开发语言·数据库·elasticsearch·搜索引擎·ai·langchain
学编程的闹钟17 分钟前
C语言GetLastError函数
c语言·开发语言·学习
梵刹古音21 分钟前
【C++】多态
开发语言·c++
山岚的运维笔记23 分钟前
SQL Server笔记 -- 第34章:cross apply
服务器·前端·数据库·笔记·sql·microsoft·sqlserver
智算菩萨30 分钟前
上下文学习的贝叶斯推断视角:隐式梯度下降还是隐式贝叶斯?
人工智能·算法
hello 早上好33 分钟前
07_JVM 双亲委派机制
开发语言·jvm