-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path100-isSameTree.h
More file actions
47 lines (34 loc) · 624 Bytes
/
100-isSameTree.h
File metadata and controls
47 lines (34 loc) · 624 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <iostream>
#include <string.h>
#include "TreeDefine.h"
class CSolution
{
public:
CSolution();
~CSolution();
public:
bool isSameTree(TreeNode* pRoot1, TreeNode* pRoot2);
private:
};
CSolution::CSolution()
{
}
CSolution::~CSolution()
{
}
//Éî¶ÈÓÅÏÈËÑË÷
bool CSolution::isSameTree(TreeNode* pRoot1, TreeNode* pRoot2)
{
if (pRoot1 == nullptr && pRoot2 == nullptr)
return true;
else if (pRoot1 && pRoot2)
{
if (pRoot1->val == pRoot2->val)
return isSameTree(pRoot1->right, pRoot2->right) && isSameTree(pRoot1->left, pRoot2->left);
else
return false;
}
else
return false;
}