Skip to content

Commit 19880b9

Browse files
committed
updating with time complexity
1 parent 5148362 commit 19880b9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Trie/wordBreakTrie.java

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ with t,e,e,l and since trie consists this, it will return true and for empty str
1414
1515
Although this problem can be solved using memoization, Tries are particularly useful, let's say if we have
1616
a very large dictionary and hence we would want to call search multiple times.
17+
18+
DP with Trie.
19+
Time complexity is O(n + m) * k, where n is the length of the String s, m is the size of the wordDict,
20+
and k is the maximum length of the word in wordDict. The Trie construction takes O(mk) time
21+
and the check of whether s can be broken into the words in wordDict takes O(nk) time.
1722
*/
1823

1924
class TrieNode {

0 commit comments

Comments
 (0)