Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit f5916fb

Browse files
committed
added problem71
1 parent 016e11b commit f5916fb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

problem71/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 1268. Search Suggestions System
2+
3+
You are given an array of strings products and a string searchWord.
4+
5+
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 searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.
6+
7+
Return a list of lists of the suggested products after each character of searchWord is typed.
8+
9+
10+
## Example 1:
11+
12+
Input: products = ["mobile","mouse","moneypot","monitor","mousepad"], searchWord = "mouse"
13+
Output: [["mobile","moneypot","monitor"],["mobile","moneypot","monitor"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]
14+
Explanation: products sorted lexicographically = ["mobile","moneypot","monitor","mouse","mousepad"].
15+
After typing m and mo all products match and we show user ["mobile","moneypot","monitor"].
16+
After typing mou, mous and mouse the system suggests ["mouse","mousepad"].
17+
18+
## Example 2:
19+
20+
Input: products = ["havana"], searchWord = "havana"
21+
Output: [["havana"],["havana"],["havana"],["havana"],["havana"],["havana"]]
22+
Explanation: The only word "havana" will be always suggested while typing the search word.
23+
24+
25+
## Constraints:
26+
27+
1 <= products.length <= 1000
28+
1 <= products[i].length <= 3000
29+
1 <= sum(products[i].length) <= 2 * 104
30+
All the strings of products are unique.
31+
products[i] consists of lowercase English letters.
32+
1 <= searchWord.length <= 1000
33+
searchWord consists of lowercase English letters.

0 commit comments

Comments
 (0)