8000 Fixed Letter Combinations of a Phone Number · sgh1992/leetcode@1359fc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1359fc5

Browse files
committed
Fixed Letter Combinations of a Phone Number
1 parent 214d907 commit 1359fc5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

C++/chapBruteforce.tex

+2
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ \subsection{递归}
733733

734734
vector<string> letterCombinations (const string &digits) {
735735
vector<string> result;
736+
if (digits.empty()) return result;
736737
dfs(digits, 0, "", result);
737738
return result;
738739
}
@@ -761,6 +762,7 @@ \subsection{迭代}
761762
"ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
762763

763764
vector<string> letterCombinations (const string &digits) {
765+
if (digits.empty()) return vector<string>();
764766
vector<string> result(1, "");
765767
for (auto d : digits) {
766768
const size_t n = result.size();

0 commit comments

Comments
 (0)
0