642. Design Search Autocomplete System

Practice Design Search Autocomplete System for free on NudgeCode: Hard, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Design the autocomplete box of a search engine. The system starts with a history: sentences[i] was typed times[i] times (its hotness). The user then types one character at a time.

Each test is a list of operations and their arguments; the expected output lists what each call returns (null for the constructor).

Example

["AutocompleteSystem","input","input","input","input"]
[[["i love you","island","iroman","i love leetcode"],[5,3,2,2]],["i"],[" "],["a"],["#"]]
->  [null,["i love you","island","i love leetcode"],["i love you","i love leetcode"],[],[]]

After the "#", "i a" is in the history with hotness 1.

Constraints