There is a list of products and a word being typed. After each typed letter, suggest up to three products that start with the letters typed so far, the smallest in alphabetical order first. Return one list per letter. Our example: products [ox, on, of, or], typed "oxen" — the answer is [[of, on, or], [ox], [], []].
input
products: different words of lowercase letters, in any order; searchWord: the word being typed, letter by letter.
returns
A list for each typed letter: up to three products that start with the letters typed so far, the first ones in alphabetical order, sorted. A list is empty when no product fits.
constraints
1 ≤ products.length ≤ 1000
1 ≤ products[i].length ≤ 3000
1 ≤ sum(products[i].length) ≤ 2·10⁴
all products are different
1 ≤ searchWord.length ≤ 1000
products and searchWord are lowercase English letters
our 11 tests keep to them
examples
Open a test in the tests panel: it shows the input and the expected answer.