Skip to content

#1268 - Search Suggestions System

MediumTrie
Open on LeetCode

Given an array of products and a searchWord, after each character of searchWord is typed, return a list of at most 3 product suggestions that have the typed prefix. Suggestions should be lexicographically sorted.

InputOutput
products = ["mobile","mouse","moneypot","monitor","mousepad"], searchWord = "mouse"[["mobile","moneypot","monitor"],["mobile","moneypot","monitor"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]

Released under the MIT License.