Your question is Trie-Based Autocomplete. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Whatnot Search needs fast prefix suggestions while a user types in the Browse experience. Given a list of unique lowercase product or seller names, build a Trie and return up to limit matching names in lexicographic order.
Implement autocomplete(words, prefix, limit). The function should return an empty list when no word starts with prefix, and it should not return more than limit results.
words, a list of unique lowercase strings; prefix, a lowercase string; and limit, a positive integer.limit strings from words that begin with prefix, ordered lexicographically.words.def autocomplete(words, prefix, limit):