-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathj. Nuts_And_Bolts.cpp
47 lines (42 loc) · 945 Bytes
/
j. Nuts_And_Bolts.cpp
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
/*
Problem Link: https://practice.geeksforgeeks.org/problems/nuts-and-bolts-problem0431/1
Title: Nuts and Bolts Problem
Difficulty: Medium
Author: Hariket Sukesh Kumar Sheth
Language: C++
*/
#include <bits/stdc++.h>
using namespace std;
class Solution{
public:
void matchPairs(char nuts[], char bolts[], int n) {
sort(nuts,nuts+n);
sort(bolts,bolts+n);
}
};
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
char nuts[n], bolts[n];
for (int i = 0; i < n; i++) {
cin >> nuts[i];
}
for (int i = 0; i < n; i++) {
cin >> bolts[i];
}
Solution ob;
ob.matchPairs(nuts, bolts, n);
for (int i = 0; i < n; i++) {
cout << nuts[i] << " ";
}
cout << "\n";
for (int i = 0; i < n; i++) {
cout << bolts[i] << " ";
}
cout << "\n";
}
return 0;
}