#include <iostream>
#include <algorithm>
#include "string"
#include "vector"
#include "stack"
#include "set"
using namespace std;
struct TreeNode
{
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
bool isSameTree(TreeNode* p, TreeNode* q)
{
/*vector<int>v1;
if (p != NULL)
{
v1.push_back(p->val);
if (p->left != NULL)
{
v1.push_back(p->left->val);
}
if (p->right != NULL)
{
v1.push_back(p->right->val);
}
}*/
if (p == NULL && q == NULL)
{
return true;
}
if (p == NULL || q == NULL)
{
return false;
}
if (p->val != q->val)
{
return false;
}
return (isSameTree(p->right, q->right)) && (isSameTree(p->left, q->left));
}
int main()
{
TreeNode t11=TreeNode(1);
TreeNode t12 = TreeNode(2);
TreeNode t13 = TreeNode(3);
t11.left = &t12;
t11.right = &t13;
TreeNode t21 = TreeNode(1);
TreeNode t22 = TreeNode(2);
TreeNode t23 = TreeNode(3);
t21.left = &t12;
t21.right = &t13;
cout<<isSameTree(&t11,&t21);
system("pause");
return 0;
}