-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubseque_nin.cpp
More file actions
45 lines (42 loc) · 1.04 KB
/
subseque_nin.cpp
File metadata and controls
45 lines (42 loc) · 1.04 KB
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
#include <bits/stdc++.h>
using namespace std;
vector<string> keypadHelper(int num, vector<string> &options)
{
if (num <= 1){
vector<string> output;
output.push_back("");
return output;
}
int lastDigit = num % 10;
int smallNumber = num / 10;
vector<string> smallOutput;
vector<string> output;
smallOutput = keypadHelper(smallNumber, options);
string op = options[lastDigit];
for (int i = 0; i < op.length(); i++){
for (int j = 0; j < int(smallOutput.size()); j++){
output.push_back(smallOutput[j] + op[i]);
}
}
return output;
}
vector<string> keypad(int num){
vector<string> options = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
vector<string> output;
output = keypadHelper(num, options);
return output;
}
int main()
{
int t;
cin >> t;
while (t--){
int n;
cin >> n;
vector<string> output = keypad(n);
for (int i = 0; i < int(output.size()); i++){
cout << output[i] << endl;
}
}
return 0;
}