-
Notifications
You must be signed in to change notification settings - Fork 3
/
Day-88
31 lines (30 loc) · 808 Bytes
/
Day-88
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
class Solution {
string getNumString(int n) {
switch(n) {
case 2: return "abc";
case 3: return "def";
case 4: return "ghi";
case 5: return "jkl";
case 6: return "mno";
case 7: return "pqrs";
case 8: return "tuv";
case 9: return "wxyz";
}
}
void getWords(int i, int n, int a[], string curr, vector<string> &res) {
if(i == n) {
res.push_back(curr);
return;
}
string s = getNumString(a[i]);
for(int j=0; j<s.size(); j++)
getWords(i+1, n, a, curr+s[j], res);
}
public:
vector<string> possibleWords(int a[], int N) {
vector<string> res;
getWords(0, N, a, "", res);
return res;
}
};
.