leetcode 100. Same Tree
来源:互联网 发布:下载模组的软件 编辑:程序博客网 时间:2024/06/17 12:12
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
void traverse(struct TreeNode* p, struct TreeNode* q, bool *f){if (!*f)return;if (p == NULL&&q != NULL || p != NULL&&q == NULL){*f = false;return;}if (p != NULL&&q != NULL){if (p->val != q->val){*f = false;return;}traverse(p->left, q->left,f);traverse(p->right, q->right,f);}return;}bool isSameTree(struct TreeNode* p, struct TreeNode* q) {bool f = true;traverse(p, q, &f);return f;}
accept
0 0
- [LeetCode]100.Same Tree
- LeetCode 100. Same Tree
- 【LeetCode】100.Same Tree
- [Leetcode] 100. Same Tree
- [Leetcode] 100. Same Tree
- LeetCode --- 100. Same Tree
- LeetCode 100. Same Tree
- [leetcode] 100.Same Tree
- leetCode 100. Same Tree
- [LeetCode]100. Same Tree
- 100. Same Tree LeetCode
- LeetCode 100. Same Tree
- LeetCode 100. Same Tree
- [LeetCode]100. Same Tree
- 【LeetCode】100. Same Tree
- leetcode 100. Same Tree
- leetcode 100. Same Tree
- 【Leetcode】100. Same Tree
- 重学数据结构系列之——图论算法之Prim算法
- 非常详细的 Docker 学习笔记
- CI框架导入数据
- 希尔排序
- Android最佳实践之Notification、下拉刷新、内存及性能建议等
- leetcode 100. Same Tree
- linux使用未解决问题
- 进程间通信 - 命名管道实现
- 第五届华中区程序设计邀请赛 网络赛Calculation E 【状压dp】
- 几种常见的窗函数
- 线程相关——HandlerThread、IntentService、ResultReceiver:结果接收者、AsyncTask:异步任务、Android中处理线程间通信的方式
- 华为OJ平台练习题
- 关于jsp乱码的一点小分析
- js原型链