Your question is Autocomplete With Prefix Matching. 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.
The lululemon app needs autocomplete suggestions while a member searches for products. Given a list of unique lowercase product-search words and a lowercase query, return every word that starts with the query, ordered lexicographically.
Implement autocomplete(words, query) using a trie. Each trie node should represent one character. After locating the node for the query, traverse its descendants to collect all matching words.
words, a list of unique lowercase strings, and query, a lowercase string.def autocomplete(words, query):