要求线性复杂度 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
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
一般不会。但我还真遇到过
肯定是变态公司, 不去也罢。
最坏还不是m * n 复杂度吗?
trie or tree?
trie 具体怎么弄?
参照 word break II https://leetcode.com/problems/word-break-ii/description/
trie == trie tree