Given a list of product names and a search word, return up to three lexicographically smallest suggestions for every prefix of the search word. Pattern focus: Trie Node Structure. A correct solution should maintain ordering, prefix traversal, and empty-result handling.
products = product catalog, searchWord = typed search text
suggestions for each prefix of searchWord
Example 1:
Input:
products = ["mobile","mouse","moneypot","monitor","mousepad"] searchWord = "mouse"
Output:
[["mobile","moneypot","monitor"],["mobile","moneypot","monitor"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]
Explanation:
Classic trie-based suggestion list where the candidate set shrinks as the prefix grows.
Example 2:
Input:
products = ["bags","baggage","banner","box","cloths"] searchWord = "bags"
Output:
[["baggage","bags","banner"],["baggage","bags","banner"],["baggage","bags"],["bags"]]
Explanation:
A longer prefix reduces the number of matching suggestions.
Example 3:
Input:
products = ["apple","orange"] searchWord = "zz"
Output:
[[],[]]
Explanation:
No product matches any prefix, so every suggestion list is empty.