Problem
You are building the suggestion box of a shop's search bar. You are given a list of products and the searchWord a customer types, one letter at a time.
After each letter typed, suggest at most three products that start with what has been typed so far. If more than three match, pick the three that come first in alphabetical order. Return one list of suggestions per typed letter.
Example 1
products = ["mobile", "mouse", "moneypot", "monitor", "mousepad"], searchWord = "mouse"
Example 2
→ [["mobile", "moneypot", "monitor"],
Example 3
["mobile", "moneypot", "monitor"],
Example 4
["mouse", "mousepad"],
Example 5
["mouse", "mousepad"],
Example 6
["mouse", "mousepad"]]
Example 7
- Input
- products = ["havana"], searchWord = "tatiana"
- Output
- [[], [], [], [], [], [], []]
Constraints
1 <= products.length <= 10001 <= products[i].length <= 30001 <= sum(products[i].length) <= 2 * 10^4All products are unique and lowercase.1 <= searchWord.length <= 1000