原题链接:https://leetcode.cn/problems/t9-lcci/
class Solution {
public:
vector<string> getValidT9Words(string num, vector<string>& words) {
vector<char> vec= {'2', '2', '2', '3', '3', '3', '4', '4', '4', '5', '5', '5', '6', '6', '6', '7', '7', '7', '7', '8', '8', '8', '9', '9', '9', '9'};
int n = num.size();
vector<string> res;
for (auto word: words) {
int i = 0;
for (; i < n; ++i) {
if (vec[word[i] - 'a'] != num[i]) {
break;
}
}
if (i == n) res.push_back(word);
}
return res;
}
};