Given the standard mapping from English letters to digits on a phone keypad:
(1 -> "",
2 -> a, b, c
3 -> d, e, f
4 -> g, h, i
5 -> j, k, l
6 -> m, n, o
7 -> p, q, r, s
8 -> t, u, v
9 -> w, x, y, z)
Write a program that outputs all words that can be formed from any n-digit phone number
from the list of given KNOWN_WORDS, considering the mapping mentioned above.
KNOWN_WORDS = ['careers', 'linkedin', 'hiring', 'interview', 'linkedgo']
phoneNumber: 2273377
Output: ['careers']
phoneNumber: 54653346
Output: ['linkedin', 'linkedgo']
这是一道典型的 手机号 → 字母映射 → 单词过滤 的面试题,核心不在暴力枚举,而在于如何高效地把 单词反向映射成数字模式。面试官重点观察候选人是否能快速识别优化方向、正确分析时间复杂度,并在解释过程中保持逻辑清晰。
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 OpenAI、Google、Amazon、Citadel、SIG 等,提供、面试辅助、代面试,帮助大家在拿 offer。
正文完