forked from larissalages/code_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1305.cpp
More file actions
33 lines (28 loc) · 636 Bytes
/
1305.cpp
File metadata and controls
33 lines (28 loc) · 636 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
class Solution {
public:
vector<int> v;
void tree1(TreeNode *root)
{
if(root!=NULL)
{
v.push_back(root->val);
tree1(root->left);
tree1(root->right);
}
}
void tree2(TreeNode *root)
{
if(root!=NULL)
{
v.push_back(root->val);
tree2(root->left);
tree2(root->right);
}
}
vector<int> getAllElements(TreeNode* root1, TreeNode* root2) {
tree1(root1);
tree2(root2);
sort(v.begin(),v.end());
return v;
}
};