[LeetCode] Same Tree
来源:互联网 发布:js 字符串加上单引号 编辑:程序博客网 时间:2024/04/23 21:21
Same Tree
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.
class Solution {public:bool isSameTree(TreeNode *p, TreeNode *q) {// Start typing your C/C++ solution below// DO NOT write int main() functionif(p==NULL&&q==NULL) return true;else if((p==NULL&&q!=NULL)||(p!=NULL&&q==NULL)) return false;else if((p->val)!=(q->val)) return false;if(isSameTree(p->left,q->left))return isSameTree(p->right,q->right);}};
- Leetcode - Tree - Same Tree
- [leetcode][tree] Same Tree
- LeetCode: Same Tree
- LeetCode Same Tree
- [Leetcode] Same Tree
- LeetCode : Same Tree
- [LeetCode] Same Tree
- leetcode 65: Same Tree
- Leetcode 100 Same Tree
- [leetcode] Same Tree
- [LeetCode]Same Tree
- [leetcode]Same Tree
- [Leetcode]Same Tree
- Leetcode: Same Tree
- [LeetCode] Same Tree
- LeetCode-Same Tree
- [leetcode] Same Tree
- LeetCode - Same Tree
- 相似度计算概述
- UVA 10341 Solve It
- 学生信息管理系统——总结
- 关于UITabBar各部分自定义的代码片段(转载)
- 2013-08-10/java基础常识|环境变量|
- [LeetCode] Same Tree
- Windows平台下Visual Studio 2010编译node-sqlite3
- Why Does GoldenGate Report The Lag Is Unknown or a Timestamp Mismatch? (Doc ID 968614.1)
- 今天我有了自己的博客
- 开源MVC框架Struts (一) 对Servlet进一步封装和抽象
- UVA 421 Polygonal Puzzle
- 操作系统各大公司笔试题汇总
- uva 140
- 查看用户表和用户权限