Search Suggestions System
Given an array of strings products
and a string searchWord
. We want to design a system that suggests at most three product names from products
after each character of searchWord
is typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.
Return list of lists of the suggested products
after each character of searchWord
is typed.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= products.length <= 1000
There are no repeated elements in
products
.1 <= Σ products[i].length <= 2 * 10^4
All characters of
products[i]
are lower-case English letters.1 <= searchWord.length <= 1000
All characters of
searchWord
are lower-case English letters.
Last updated