FastPrepAutocomplete Words by Prefix
Problems/Autocomplete Words by Prefix

Autocomplete Words by Prefix

Microsoft logoMicrosoft● EasyFULLTIMEONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Bing Applied Scientist internship report asks for all vocabulary words matching a prefix. Case sensitivity, duplicate removal, lexicographic ordering, lowercase input, interface, and bounds are conventional enrichment.

Given a vocabulary array words and a string prefix, return every distinct vocabulary word that starts with prefix.

Matching is case-sensitive. Return the results in lexicographic order.

Function

autocomplete(words: String[], prefix: String) → String[]

Examples

Example 1

words = ["dog","door","deer","doom","door"]prefix = "do"return = ["dog","doom","door"]

The three distinct matching words are returned once in lexicographic order.

Example 2

words = ["apple","banana"]prefix = "cat"return = []

No vocabulary word begins with cat.

Constraints

  • 0 <= words.length <= 100000
  • 0 <= words[i].length, prefix.length <= 100
  • Every word and the prefix contain only lowercase English letters.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Compress Consecutive Integer RangesDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
  • Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
  • Type-Ahead Prefix MatchesNavan · ONSITE INTERVIEWNavan interview questions
  • Count Word FrequenciesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Most Voted CandidateExpedia · ONSITE INTERVIEWExpedia interview questions
  • Anagrams of a Word in a Word ListZillow · PHONE SCREEN · ONSITE INTERVIEWZillow interview questions
  • Travelers per Consecutive City TripletUber · ONSITE INTERVIEWUber interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[] autocomplete(String[] words, String prefix) {
      // Write your code here.
    }

}
Checking account…