class Solution {
public List<String> getValidT9Words(String num, String[] words) {
String s = "22233344455566677778889999";
int[] d = new int[26];
for (int i = 0; i < 26; ++i) {
d[i] = s.charAt(i);
}
List<String> ans = new ArrayList<>();
int n = num.length();
for (String w : words) {
boolean ok = true;
for (int i = 0; i < n; ++i) {
if (d[w.charAt(i) - 'a'] != num.charAt(i)) {
ok = false;
break;
}
}
if (ok) {
ans.add(w);
}
}
return ans;
}
}