You are given a (potentially large) list of words.
Some words are compound words, meaning they are composed of two or more words that also exist in the same list.
Example word list:[rockstar, rock, star, rocks, tar, stars, rockstars, super, highway, high, way, superhighway]
Goal:
Identify all combinations where a word can be decomposed into two or more words from the list.
Example Output:
[
[rock, star],
[super, highway],
[super, high, way],
...
]
用 DP + 哈希集合 。
对每个单词做分词 DP,能被拆成两个以上列表中的单词就加入结果。
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 Google、Amazon、Citadel、SIG 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。