We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 252b74c commit 126a6f0Copy full SHA for 126a6f0
872.cpp
@@ -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