


Operation 1 - insert(word) - To insert a string WORD in the Trie.
Operation 2- search(word) - To check if a string WORD is present in Trie or not.
Operation 3- startsWith(word) - To check if there is a string that has the prefix WORD.

The above figure is the representation of a Trie. New words that are added are inserted as the children of the root node.
Alphabets are added in the top to bottom fashion in parent to children hierarchy. Alphabets that are highlighted with blue circles are the end nodes that mark the ending of a word in the Trie.
Type = ["insert", "search"], Query = ["coding", "coding].
We return ["null", "true"] as coding is present in the trie after 1st operation.
The first input line contains an integer 'Q' representing the number of queries.
The next line contains an array that defines the type of the query.
The next line contains the words on which we have to perform operations.
The only line contains an array that contains the answer to the query that is "true" or "false" for 2nd and 3rd type of operation and "null" for 1st operation.
We are given two functions, insert and search, both taking a single string as the only parameter.
Complete String
Complete String
Complete String
Complete String
Complete String
Complete String
Similar Name
Similar Name
Similar Name
Similar Name
Auto Suggestion
Auto Suggestion
Auto Suggestion
Auto Suggestion
Auto Suggestion
Auto Suggestion
Palindrome Pairs
Design Search Autocomplete System
Design Search Autocomplete System
Design Search Autocomplete System
Design Search Autocomplete System
Design Search Autocomplete System
Design Search Autocomplete System