A trie or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings Implement the Trie class: 1. Trie(): Initializes the trie object. 2. void insert(String word): Inserts the string word into the trie. 3. boolean search(String word): Returns true if the string word is in the trie (i.e., was inserted before), and false otherwise. 4. boolean startsWith(String prefix): Returns true if there is a previously inserted string word that has the prefix prefix, and false otherwise.
Input Format
Input is managed for you
Output Format
Output is managed for you
Constraints
1. 1 <= word.length, prefix.length <= 2000 2. word and prefix consist only of lowercase English letters.
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
insert apple search apple search app startsWith app insert app search app
Output
true false true true