Skip to content

Commit 126a6f0

Browse files
committed
872
1 parent 252b74c commit 126a6f0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

872.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
class Solution {
3+
public:
4+
bool leafSimilar(TreeNode* root1, TreeNode* root2) {
5+
vector<int>A1;
6+
vector<int>A2;
7+
searchTree(root1,A1);
8+
searchTree(root2,A2);
9+
return A1==A2;
10+
}
11+
12+
13+
void searchTree(TreeNode *root , vector<int>&A){
14+
if(root==NULL){
15+
return ;
16+
}
17+
if(root->left==NULL && root->right==NULL){
18+
A.push_back(root->val);
19+
}
20+
searchTree(root->left,A);
21+
searchTree(root->right,A);
22+
}
23+
24+
25+
};

0 commit comments

Comments
 (0)