Company: Wayfair
Difficulty: medium
Question 2 For an array of n strings products and a word to search, search, design a system that, when each character of the searched word is typed, suggests at most three product names from the products array. The suggested products should share a common prefix with the searched word. If more than three products exist with a common prefix, report the three product names that appear first in lexicographical order. Return the suggested products, which will be a list of lists after each character of the searched word is typed. Note: A string x is considered lexicographically smaller than another string y if x will occur before y in the English dictionary. Function Description Complete the function getProductSuggestions in the editor below. getProductSuggestions has the following parameter(s): string products[n] : the list of products string search : a string Returns string[n][] : for each prefix of the string, return a maximum of three lexicographically smallest words with a common prefi