class Solution
{
map<char,string> digitComb
{
{'2', "abc"},
{'3', "def"},
{'4', "ghi"},
{'5', "jkl"},
{'6', "mno"},
{'7', "pqrs"},
{'8', "tuv"},
{'9', "wxyz"}
};
vector<string> res;
string digits;
public:
void DFS(int i = 0, string curStr = "")
{
if (curStr.size() == digits.size())
{
res.push_back(curStr);
return;
}
for (auto& c : digitComb[digits[i]])
DFS(i + 1, curStr + c);
}
vector<string> letterCombinations(string digits)
{
this->digits = digits;
if (digits.size())
DFS();
return res;
}
};
'코딩테스트 > LeetCode' 카테고리의 다른 글
[LeetCode] Evaluate Reverse Polish Notation (0) | 2023.12.11 |
---|---|
[LeetCode] Rotate Array (0) | 2023.12.08 |
[LeetCode] Merge Sorted Array (0) | 2023.12.08 |
[LeetCode] Length of Last Word (0) | 2023.12.06 |
[LeetCode] 34 - Find First and Last Position of Element in Sorted Array (0) | 2023.11.02 |