Find Every Reachable Derived Vocabulary Word
Updated
Problem statement
A word directly derives from another word when it can be formed by rearranging all of that word's letters and adding exactly one new letter. Keep every existing letter, including repeated copies. You cannot remove or replace any of them.
Given start and vocabulary, return every vocabulary word reachable from start through one or more direct derivations.
For this exercise, assume every intermediate and resulting word after start must be listed in vocabulary. The start need not be listed. Equal-length anagrams of start are not derivatives because every step adds one letter.
For this exercise, assume vocabulary labels are unique and all words are nonempty lowercase English strings of length at most 12. Return each reachable word once in alphabetical order; an empty vocabulary returns an empty array.
Function
deriveVocabulary(start: String, vocabulary: String[]) → String[]Examples
Example 1
start = "two"vocabulary = ["wout"]return = ["wout"]two reaches wout: rearrange the letters and add u.
Example 2
start = "two"vocabulary = ["woutx","two"]return = []This example has no listed intermediate of length four, so woutx is unreachable under the declared vocabulary-step rule.
Example 3
start = "ab"vocabulary = ["abcd","acb","abc","bca"]return = ["abc","abcd","acb","bca"]This example reaches three anagrams directly and abcd through a listed length-three intermediate.
Constraints
- For this exercise, assume
0 <= vocabulary.length <= 200. 1 <= start.length, vocabulary[i].length <= 12; every character is a lowercase English letter.- Vocabulary words are unique, and every intermediate after start must be a vocabulary word.
More Duolingo Phone Screen questions
- Rank Word-Translation Hints from Sentence TranslationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Group Timestamps into Consecutive-Day IntervalsPHONE SCREEN · Seen Nov 2026
- Return Every Matching DecryptionPHONE SCREEN · Seen Nov 2026
- Visit Desired Attractions Without Reusing a TrailPHONE SCREEN · Seen Oct 2026
- Correct an In-Place Array ReversalPHONE SCREEN · Seen Oct 2026
- Count Starts Reaching a Grid MaximumPHONE SCREEN · Seen Oct 2026
- Select the Top User MatchesPHONE SCREEN · Seen Oct 2026
- Sum All Values in a Binary TreePHONE SCREEN · Seen Oct 2026
- User Resource Transition ProbabilitiesPHONE SCREEN · Seen Oct 2026
- Encrypt and Decrypt StringsPHONE SCREEN · Seen Apr 2026
Similar questions at other companies
- Resource Transition ProbabilitiesWhatNot · PHONE SCREENWhatNot interview questions
- Mutual-Friend Referral RecommendationsFireworks AI · PHONE SCREEN · ONSITE INTERVIEW
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Group AnagramsWorkday · PHONE SCREEN
- Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
- Nested Substitutions with Cycle DetectionKikoff · PHONE SCREENKikoff interview questions
- Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
- Time-Aware Search AutocompleteRoblox · PHONE SCREENRoblox interview questions