-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (33 loc) · 792 Bytes
/
Copy pathmain.cpp
File metadata and controls
37 lines (33 loc) · 792 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
//
// main.cpp
// leetcode101
//
// 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 judge(TreeNode* p, TreeNode* q){
if(!p && !q)
return true;
else if(!p || !q)
return false;
if(p->val != q -> val)
return false;
return judge(p->left, q -> right) && judge(p -> right, q -> left);
}
bool isSymmetric(TreeNode* root) {
return judge(root->left, root -> right);
}
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}