mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
delete misplaced file
This commit is contained in:
parent
e8caf31e0c
commit
8b3b46f8cc
43
872.c
43
872.c
@ -1,43 +0,0 @@
|
||||
/**
|
||||
* Definition for a binary tree node.
|
||||
* struct TreeNode {
|
||||
* int val;
|
||||
* struct TreeNode *left;
|
||||
* struct TreeNode *right;
|
||||
* };
|
||||
*/
|
||||
|
||||
|
||||
bool leafSimilar(struct TreeNode* root1, struct TreeNode* root2){
|
||||
int sequence1[100] ={0}, sequence2[100]={0}, num_of_node1 =0,num_of_node2 =0;
|
||||
|
||||
num_of_node1 = sequence(root1,sequence1,num_of_node1);
|
||||
num_of_node2 = sequence(root2,sequence2,num_of_node2);
|
||||
|
||||
if (num_of_node1 != num_of_node2)
|
||||
return false;
|
||||
|
||||
for (int i = 0;i<num_of_node1; i++){
|
||||
if (sequence1[i] != sequence2[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int sequence(struct TreeNode* root ,int *list , int num_of_node){
|
||||
|
||||
if (!root)
|
||||
return num_of_node;
|
||||
|
||||
if (!root->left && !root->right){
|
||||
list[num_of_node] = root->val;
|
||||
num_of_node ++;
|
||||
return num_of_node;
|
||||
}
|
||||
|
||||
num_of_node = sequence(root->left ,list , num_of_node);
|
||||
num_of_node = sequence(root->right ,list , num_of_node);
|
||||
|
||||
return num_of_node;
|
||||
}
|
Loading…
Reference in New Issue
Block a user