MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / wordBreak0

Function wordBreak0

word_break_139/solution.go:36–44  ·  view source on GitHub ↗

Recursive solution, which exceeds the time limit.

(s string, wordDict []string)

Source from the content-addressed store, hash-verified

34
35// Recursive solution, which exceeds the time limit.
36func wordBreak0(s string, wordDict []string) bool {
37 // create a set of words in wordDict for fast lookup
38 wordDictSet := make(map[string]bool)
39 for _, w := range wordDict {
40 wordDictSet[w] = true
41 }
42
43 return wordBreakHelper(s, wordDictSet, 0)
44}
45
46func wordBreakHelper(s string, wordDictSet map[string]bool, start int) bool {
47 // if we've reached the start of s, the string has been broken up

Callers 1

Test_wordBreakFunction · 0.85

Calls 1

wordBreakHelperFunction · 0.85

Tested by 1

Test_wordBreakFunction · 0.68