Implement Trie (Prefix Tree)
00:00
AmazonGoogleMicrosoft
Design a Trie supporting insert(word), search(word), and startsWith(prefix). All operations O(m) where m = word length.
Examples
Input → insert('apple'), search('apple')
Output → True, search('app')→False, startsWith('app')→True
Input → insert('cat'),insert('car'), search('car')
Output → True, startsWith('ca')→True
Input → insert('a'), search('ab')
Output → False