Loading...
Implement a Trie that supports insert, search, and startsWith operations.
Input: Line 1: comma-separated operations (insert/search/startsWith). Line 2: comma-separated arguments. Output: Result of each search/startsWith operation, one per line.
insert,search,search,startsWith,insert,search apple,apple,app,app,app,app
True False True True
insert, search, search, startsWith, insert, search and the arguments are apple, apple, app, app, app, app.apple is inserted, allowing the first search for apple to return True.search for app returns False because app is not a complete word in the Trie, and startsWith for app returns True because app is a prefix of apple.app into the Trie, the final search for app returns True.