Problem
You get an array of strings products and a string searchWord. A user types searchWord one character at a time.
After each character, the system suggests at most three products. Each suggested product must start with the characters that the user typed so far. If more than three products match, suggest the first three products in lexicographic order.
Lexicographic order is the order of words in a dictionary. For example, "tab" comes before "table", and "table" comes before "tap".
Return a list of lists. List i holds the suggestions after the user types the first i + 1 characters. Put the suggestions in each list in lexicographic order.
Example 1
- Input:
- products = ["table","tablet","tab","tap","toast","tea"], searchWord = "tap"
- Output:
- [["tab","table","tablet"],["tab","table","tablet"],["tap"]]
- Explanation:
- Six products start with
"t"and four products start with"ta". Only"tap"starts with"tap".
Example 2
- Input:
- products = ["kiwi"], searchWord = "kite"
- Output:
- [["kiwi"],["kiwi"],[],[]]
- Explanation:
- No product starts with
"kit", so the last two lists are empty.
Example 3
- Input:
- products = ["melon","mango","map","mint","mug"], searchWord = "ma"
- Output:
- [["mango","map","melon"],["mango","map"]]
Constraints
- 1 <= products.length <= 1000
- 1 <= products[i].length <= 3000
- 1 <= sum(products[i].length) <= 2 * 10^4
- All strings in products are unique.
- products[i] has only lowercase English letters.
- 1 <= searchWord.length <= 1000
- searchWord has only lowercase English letters.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- All Elements in Two Binary Search Trees
Coding
- Autocomplete User Search
Coding
- Balance a Binary Search Tree
Coding
- Binary Search
Coding · Array · Binary Search
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
eBay
Leetcode 1268. Search Suggestions System
Reported May 28, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 1268. Search Suggestions System
Reported Feb 15, 2026 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View sourceMiro
Leetcode 1268. Search Suggestions System
Reported Nov 18, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View source