660. Search Suggestions System
We need to create a system that suggests up to three product names from a given list of products after each character of a search word is entered. The suggested products should have a common prefix with the search word. If there are more than three products with a common prefix, we should return the three lexicographically smallest products. The output should be a list of lists, showing the suggested products after each character of the search word is entered.
The first line of input represents N, the number of words. The next N lines contain the words to be searched. The last line contains the search word.
The desired output is a list of words.
5 mobile mouse moneypot monitor mousepad mouse
[["mobile", "moneypot", "monitor"], ["mobile", "moneypot", "monitor"], ["mouse", "mousepad"], ["mouse", "mousepad"], ["mouse", "mousepad"]]
The number of words to be searched is less than 1000.