-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (32 loc) · 721 Bytes
/
Copy pathmain.cpp
File metadata and controls
36 lines (32 loc) · 721 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
//
// main.cpp
// leetcode100
//
// Created by 萧天牧 on 17/4/18.
// Copyright © 2017年 萧天牧. All rights reserved.
//
#include <iostream>
using namespace std;
// Definition for a binary tree node.
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
bool isSameTree(TreeNode* p, TreeNode* q) {
if(!p){
if(!q)
return true;
else
return false;
}
if(!q)
return false;
bool flag = true;
if(p->val != q->val)
flag = false;
return flag && isSameTree(p->left, q->left) && isSameTree(p -> right, q->right);
}
int main(int argc, const char * argv[]) {
}