-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdsaArray5.cpp
More file actions
47 lines (33 loc) · 819 Bytes
/
dsaArray5.cpp
File metadata and controls
47 lines (33 loc) · 819 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// { Driver Code Starts
//Initial template for C++
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
//User function template in C++
class Solution{
public:
//Function to return the count of number of elements in union of two arrays.
int doUnion(int a[], int n, int b[], int m) {
unordered_set<int>s(a,a+n);
for(int i=0;i<m;i++)
s.insert(b[i]);
return s.size();
}
};
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while(t--){
int n, m;
cin >> n >> m;
int a[n], b[m];
for(int i = 0;i<n;i++)
cin >> a[i];
for(int i = 0;i<m;i++)
cin >> b[i];
Solution ob;
cout << ob.doUnion(a, n, b, m) << endl;
}
return 0;
} // } Driver Code Ends