Skip to content

Commit

Permalink
相同的树
Browse files Browse the repository at this point in the history
  • Loading branch information
money89757 authored Aug 22, 2018
1 parent da4b8cc commit ceb1579
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 算法/LeetCode/isSameTree.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

struct TreeNode{
int val;
struct TreeNode *left;
struct TreeNode *right;
};

int isSameTree(struct TreeNode *p, struct TreeNode *q)
{
if(p != NULL && q != NULL)
{
if(p->val != p->val)
{
return 0;
}
if(!isSameTree(p->left,q->left))
return 0;
if(!isSameTree(p->right,p->right))
return 0;
}
else
return p == q;

return 1;
}

0 comments on commit ceb1579

Please sign in to comment.