FastPrepAnagrams of a Word in a Word List
Problems/Anagrams of a Word in a Word List

Anagrams of a Word in a Word List

Zillow logoZillow● EasyFULLTIMEINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Asked at Zillow in 2013, in two reports. A software engineering intern candidate first did a coding challenge, then two phone interviews and then three interviews on site; the report lists this question without saying which of these steps it came in. A software development engineer candidate, who gave no level, had a coding test, a 20-minute phone interview and three on-site whiteboard interviews; the report names this task apart from the coding test and does not say whether it came in the phone interview or on site.

Both reports give the candidate one word and a list of English words, and ask for the words in the list that can be formed by rearranging the letters of that word.

The reports do not say in what order to return the matches, whether letter case matters, how repeated letters count, whether the word itself counts, or how long the list is. Here the function gets the word as a string and the list as an array of strings, and returns the matching words as an array, in their order in the list, or an empty array when none match. A match must use every letter of the word exactly as many times as the word does, and the word itself counts when it is in the list. All words are lowercase, the words in the list are all different, and the list holds 1 to 10^4 words of 1 to 20 letters; these limits are ours.

Our version is about 90% the same as the reported question.

Given a string word and an array of strings dictionary that holds valid English words, return every word in dictionary that is an anagram of word.

An anagram of word is a word made by rearranging all the letters of word: it uses each letter exactly as many times as word does, so it also has the same length. word counts as an anagram of itself, so if word is in dictionary, it is part of the answer.

Return the matching words in the order they appear in dictionary. If no word matches, return an empty array.

Function

findWordAnagrams(word: String, dictionary: String[]) → String[]

Examples

Example 1

word = "tops"dictionary = ["post","pots","stop","stops","top","spot","pest"]return = ["post","pots","stop","spot"]

"post", "pots", "stop" and "spot" each use the letters t, o, p and s once, like "tops". "stops" and "top" have a different length, and "pest" has an e instead of an o. The four matches keep their order from dictionary.

Example 2

word = "stressed"dictionary = ["desserts","dessert","stresses","stressed"]return = ["desserts","stressed"]

"stressed" has three s, two e, one t, one r and one d. "desserts" has the same counts. "dessert" is one letter short, and "stresses" has four s and no d. "stressed" itself is in dictionary, so it is part of the answer.

Example 3

word = "apple"dictionary = ["appeal","pale","leap"]return = []

"pale" and "leap" use only some of the letters of "apple", and "appeal" has one letter too many. No word matches, so the answer is an empty array.

Constraints

  • 1 <= dictionary.length <= 104
  • 1 <= word.length <= 20
  • 1 <= dictionary[i].length <= 20
  • word and every dictionary[i] consist only of lowercase English letters.
  • All the words in dictionary are different.

More Zillow Onsite Interview questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
  • First Subarray with the Largest SumOA · ONSITE INTERVIEW · Seen Aug 2021
  • Count Duplicate CharactersONSITE INTERVIEW · Seen Oct 2020
  • Decision Tree Classifier from ScratchONSITE INTERVIEW · Seen Nov 2019
  • Find Median from Data StreamPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2018
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2016
  • Tic-Tac-Toe Winner on a Huge BoardPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2016
  • Most Frequent Three-Page SequencesPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2016

Similar questions at other companies

  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Parse and Sort Integer DataLegora · PHONE SCREEN
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • Compress Consecutive Integer RangesDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Filter Anagrams of a TargetMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
  • Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
  • Remove Later Anagrams From a ListBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Type-Ahead Prefix MatchesNavan · ONSITE INTERVIEWNavan interview questions
All Zillow interview questionsSee Zillow hiring insights
Saved
class Solution {
    public String[] findWordAnagrams(String word, String[] dictionary) {
        // Write your code here.
    }
}
Checking account…