这道题目要用kmp 算法吗?

l
liu.neng
楼主 (北美华人网)
要求线性复杂度 Given a class such as:
Class WordsFinder {
}
And an input text file contains a list of words. The list contains all the words in the English language dictionary (approximately 600,000+ words). Example: ================== apple cat table dog from fish select selected
... ==================
Implement the method "findWords(String str)" so that when given any input string, return the valid words that were found in the text file and the indexes that they appear in this string
Example: If an input string "abcSELECTxyzFrom123Table selected@567" was passed into the method findWords The program should be able to find the words and the indexes they appear in the string such as "select": 3, 25 "from": 12 "table": 19 "selected": 25
t
tyshsh
Robin karp. 面试不会考kmp.
g
gokgs
不是 trie?
f
fibril
Robin karp. 面试不会考kmp.
tyshsh 发表于 2021-07-02 19:03

一般不会。但我还真遇到过
g
gokgs
一般不会。但我还真遇到过

fibril 发表于 2021-07-02 19:11

肯定是变态公司, 不去也罢。
n
nazaban
Robin karp. 面试不会考kmp.
tyshsh 发表于 2021-07-02 19:03

最坏还不是m * n 复杂度吗?
千渔千寻
Trie Tree
l
liu.neng
Trie Tree

千渔千寻 发表于 2021-07-02 21:27

trie or tree?
l
liu.neng
不是 trie?
gokgs 发表于 2021-07-02 19:08

trie 具体怎么弄?
g
gokgs
trie 具体怎么弄?
liu.neng 发表于 2021-07-02 21:36

参照 word break II https://leetcode.com/problems/word-break-ii/description/
千渔千寻
回复 8楼liu.neng的帖子
trie == trie tree