FastPrepMaximum-Value Word Derivation Path
Problems/Maximum-Value Word Derivation Path

Maximum-Value Word Derivation Path

Duolingo logoDuolingo● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task asks for the best-value path between fixed ends, and our version matches it at about 80%. It keeps the original relation: rearrange the letters and add one letter. We wrote all the examples that have full weights. We chose these rules. Intermediate words and end words must be listed. Values can be negative but are finite. Sums include both ends. Ties go to the first path in alphabetical order. A path with zero steps and an unreachable end both have set answers.

In one derivation step, rearrange all the letters of a word and add exactly one letter. Existing letters cannot be removed or replaced, and repeated letters count separately.

Each vocabulary[i] has integer value values[i]. Given start and target, return a derivation path from start to target whose total word value is largest.

For this exercise, assume vocabulary labels are unique, both endpoints are listed, and every intermediate word must also be listed. The total includes every word in the path, including start and target.

For this exercise, assume equal totals choose the lexicographically smallest complete word list: compare the first differing word using ordinary lowercase lexicographic order. Return an empty array if target is unreachable. When start equals target, return the one-word zero-step path.

Function

bestDerivationPath(start: String, target: String, vocabulary: String[], values: int[]) → String[]

Examples

Example 1

start = "a"target = "abc"vocabulary = ["a","ab","ac","abc"]values = [1,3,8,2]return = ["a","ac","abc"]

This example chooses a, ac, abc with total 11 instead of the total 6 through ab.

Example 2

start = "ab"target = "abcd"vocabulary = ["ab","abc","acb","abcd"]values = [2,5,5,3]return = ["ab","abc","abcd"]

This tie selects ab, abc, abcd before ab, acb, abcd in lexicographic path order.

Example 3

start = "two"target = "woutx"vocabulary = ["two","woutx"]values = [4,9]return = []

There is no listed length-four intermediate word, so no path exists.

Constraints

  • For this exercise, assume 1 <= vocabulary.length <= 25 and values.length == vocabulary.length.
  • Every vocabulary word is a unique nonempty lowercase English string of length at most 12. Start and target occur in vocabulary.
  • For this exercise, assume -1000 <= values[i] <= 1000.

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

  • Shortest Word Chain Between Two WordsFanatics · PHONE SCREEN
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Minimum Total Layover WaitGoogle · PHONE SCREENGoogle interview questions
  • Longest Palindromic SubstringSiemens · PHONE SCREEN
  • Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Edit DistanceDP World · PHONE SCREEN
  • Nested Substitutions with Cycle DetectionKikoff · PHONE SCREENKikoff interview questions
  • Shortest Paths in a Nonnegative Directed GraphNation with NaMo · PHONE SCREEN

Duolingo interview experiences

  • Duolingo interviews · November 2026
  • Duolingo SWE Interview Questions: 3 Experiences
All Duolingo interview questionsSee Duolingo hiring insights
Saved
class Solution {
    public String[] bestDerivationPath(String start, String target, String[] vocabulary, int[] values) {
        // Write your code here.
        return new String[0];
    }
}
Checking account…