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

Method search

implement_trie_208/solution.go:51–67  ·  view source on GitHub ↗
(word string, needsEnd bool)

Source from the content-addressed store, hash-verified

49}
50
51func (this *Trie) search(word string, needsEnd bool) bool {
52 curr := this.root
53 for i := 0; i < len(word); i++ {
54 slot := word[i] - 'a'
55 if curr.children[slot] == nil {
56 return false
57 }
58
59 curr = curr.children[slot]
60 }
61
62 if needsEnd {
63 return curr.end
64 }
65
66 return true
67}

Callers 2

SearchMethod · 0.95
StartsWithMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected