FastPrepFilter Anagrams of a Target
Problems/Filter Anagrams of a Target

Filter Anagrams of a Target

Microsoft logoMicrosoft● EasyFULLTIMEINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft onsite interview. The report asks to filter a list by anagram match and talks about how to design the key. It leaves out the order, repeats, the alphabet and the size rules. Our version is about 88% the same as the reported question.

Given an array of lowercase strings words and a lowercase string target, return every entry of words that is an anagram of target.

Two strings are anagrams when they contain exactly the same letters with the same frequencies. Preserve the original order of matching entries, and preserve duplicate entries.

Function

filterTargetAnagrams(words: String[], target: String) → String[]

Examples

Example 1

words = ["eat","tea","tan","ate","nat","bat"]target = "aet"return = ["eat","tea","ate"]

eat, tea, and ate have the same letter frequencies as aet. They remain in their input order.

Example 2

words = ["abc","abb","bca","abc"]target = "cab"return = ["abc","bca","abc"]

Both copies of abc and the entry bca match. The nonmatching entry abb is omitted.

Constraints

  • 1 <= words.length <= 10^5
  • 1 <= target.length <= 10^5
  • The total length of all strings in words is at most 2 * 10^5.
  • Every string contains 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
  • Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
  • Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
  • Count Word FrequenciesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Most Voted CandidateExpedia · ONSITE INTERVIEWExpedia interview questions
  • List Each Name Once, AlphabeticallyDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Process Shopping Records, Promotions, and Display OrderInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Group Duplicate Files by ContentPostman · ONSITE INTERVIEWPostman interview questions

Interview reports that mention this question

  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

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)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[] filterTargetAnagrams(String[] words, String target) {
      // write your code here
    }
}
Checking account…