Create a Trie data structure to support efficient insertion and lookup of words.
HardProblem Statement
Create a Trie data structure to support efficient insertion and lookup of words.
Sample Input
Insert("go"); Search("go")Sample Output
true
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
package main
import "fmt"
type Trie struct {
// Your code here
}
func NewTrie() *Trie {
return &Trie{}
}
func main() {
trie := NewTrie()
trie.Insert("go")
fmt.Println(trie.Search("go")) // Expected Output: true
fmt.Println(trie.Search("golang")) // Expected Output: false
}
Input
Insert("go"); Search("go")Expected Output
true