Search Suggestions System

Given unique lowercase product names and a lowercase search word, return one row for every nonempty prefix of the search word. Each row contains at most three lexicographically smallest products beginning with that prefix. Return an empty row when no product matches.

  • Input: products = ["mobile", "mouse", "moneypot", "monitor", "mousepad"], searchWord = "mouse"
  • Output: [["mobile","moneypot","monitor"],["mobile","moneypot","monitor"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]
Examples
Input: []
Output: 0
Hints

Search Suggestions System

Given unique lowercase product names and a lowercase search word, return one row for every nonempty prefix of the search word. Each row contains at most three lexicographically smallest products beginning with that prefix. Return an empty row when no product matches.