# #100 Same Tree

/**
* Definition for a binary tree node.
* struct TreeNode {
*     int val;
*     TreeNode *left;
*     TreeNode *right;
*     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool isSameTree(TreeNode* p, TreeNode* q) {
if ( p == NULL && q == NULL ) {
return true;
}
else if ( p != NULL && q != NULL ) {
if ( p->val != q->val ) return false;
return isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
}
else return false;
}
};

• 本文已收录于以下专栏：

## 100. Same Tree和判断一个树是不是对称的思想一样

Given two binary trees, write a function to check if they are equal or not.Two binary trees are cons...

## LeetCode 100. Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are co...

## LeetCode之路：100. Same Tree

LeetCode之路：100. Same Tree 一、引言这道题其实还算比较简单，主要考察的是对于二叉树的理解，就像我之前“大胆”总结的： 使用递归能解决 80% 的二叉树问题 仿佛这道题也没有...

## Leetcode 100. Same Tree

Given two binary trees, write a function to check if they are equal or not.Two binary trees are cons...

## [LeetCode]100.Same Tree

【题目】 Same Tree  Total Accepted: 4943 Total Submissions: 11464My Submissions Given two binary...

## [leetcode:python]100.Same Tree

• NXHYD
• 2017-05-11 10:01
• 88

## [Leetcode 100] Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...

## 【Leetcode】100.Same Tree

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)