Given a dictionary/list of words, take a typed substring as input and return all words in the dictionary that start with that substring (i.e. implement Google Search-style autocomplete).
Asked in the onsite coding round stage. Candidate noted the problem felt closely related to Google's core search/autocomplete business; unsure if it's a commonly recurring question.
Implement autocomplete(words, prefix). Return matching words in lexicographic order. An empty prefix matches every word.
def autocomplete(words, prefix):