8000 2 · javasharper/leetcode@f64e60f · GitHub
[go: up one dir, main page]

Skip to content

Commit f64e60f

Browse files
committed
2
1 parent eab2220 commit f64e60f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

LetterCombinationsofaPhoneNumber/LetterCombinationsofaPhoneNumber.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11

2-
const string Solution::keypad[8] = {"abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
3-
42
class Solution {
5-
public:
3+
private:
64
static const string keypad[8];
5+
public:
76
vector<string> letterCombinations(string digits) {
87
// Start typing your C/C++ solution below
98
// DO NOT write int main() function
109

1110
vector<string> all_letters;
1211
string letter;
12+
13+
if (digits.empty()) {
14+
all_letters.push_back(letter);
15+
return all_letters;
16+
}
17+
1318
letterCombinationsHelper(digits, 0, letter, all_letters);
1419
}
1520
void letterCombinationsHelper(string& digits, int step, string& letter, vector<string>& all_letters) {
@@ -25,3 +30,5 @@ class Solution {
2530
}
2631
}
2732
};
33+
34+
const string Solution::keypad[8] = {"abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

0 commit comments

Comments
 (0)
0