afatnan
Senior Member
C++:
class Solution {
private:
vector<vector<char>> table = {
{'a', 'b', 'c'},
{'d', 'e', 'f'},
{'g', 'h', 'i'},
{'j', 'k', 'l'},
{'m', 'n', 'o'},
{'p', 'q', 'r', 's'},
{'t', 'u', 'v'},
{'w', 'x', 'y', 'z'},
};
public:
vector<string> letterCombinations(string digits) {
if(digits.size() == 0) return {};
vector<string> res = {""};
for(char c : digits){
vector<string> tmp;
for(char ch : table[c - '0' - 2])
for(string s : res) tmp.push_back(s + ch);
res = tmp;
}
return res;
}
};




). ông nào thích code nhiều thì cứ java mà phang