Given an array of words, implement a system where entering a few letters returns all word strings starting with that substring (similar to Google Search autocomplete).
Asked in the Onsite stage. This coding round question was described as highly relevant to Google's search business.
Implement autocomplete(words, prefix). Return every word beginning with prefix, in lexicographic order. Matching is case-sensitive, and duplicate input words must remain duplicated in the output.
def autocomplete(words, prefix):