FastPrepUser Resource Transition Probabilities
Problems/User Resource Transition Probabilities

User Resource Transition Probabilities

Duolingo logoDuolingo● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes how each user moves between resources, with START and END markers. It does not say how ties work or what order the output is in. We chose those. Our version is about 93% the same as the reported question.

You are given an unsorted event log logs. Each row has the form [time, user, resource], where time is a nonnegative decimal timestamp.

Build each user's chronological resource sequence independently. Sort that user's events by numeric timestamp; when two events have the same timestamp, preserve their original order in logs. Add START before the first resource and END after the last resource.

Count every adjacent transition across all user sequences. For each observed transition, return one row in the exact form current->next:count/total, where total is the number of outgoing transitions observed from current. Do not reduce the fraction.

Sort the returned rows lexicographically by current, then by next. User sequences never connect to one another.

Function

userResourceTransitionProbabilities(logs: String[][]) → String[]

Examples

Example 1

logs = [["3","alice","cart"],["1","alice","home"],["2","bob","search"],["2","alice","search"]]return = ["START->home:1/2","START->search:1/2","cart->END:1/1","home->search:1/1","search->END:1/2","search->cart:1/2"]

Alice's sequence is START, home, search, cart, END, while Bob's is START, search, END. Their transition counts are combined only after each sequence is complete.

Example 2

logs = [["5","user","b"],["5","user","a"],["4","other","c"]]return = ["START->b:1/2","START->c:1/2","a->END:1/1","b->a:1/1","c->END:1/1"]

The equal-time events for user keep their input order, so that sequence is START, b, a, END.

Example 3

logs = [["2","a","x"],["1","a","x"],["1","b","x"]]return = ["START->x:2/2","x->END:2/3","x->x:1/3"]

User a contributes x->x and one x->END; user b contributes the other x->END.

Constraints

  • 1 <= logs.length <= 2 * 10^5.
  • Every row contains exactly three strings: [time, user, resource].
  • 0 <= time <= 10^9, written as an ordinary decimal integer.
  • Each user contains 1 to 30 lowercase English letters or digits.
  • Each resource contains 1 to 30 lowercase English letters and is different from START and END.

More Duolingo Phone Screen questions

  • 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
  • Encrypt and Decrypt StringsPHONE SCREEN · Seen Apr 2026
  • Validate a Mahjong Hand PartitionPHONE SCREEN · Seen Nov 2025
  • Directional Tiles: Find a Valid Reconfiguration PathPHONE SCREEN · Seen Oct 2022

Similar questions at other companies

  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Build a Task and Subtask HierarchyStripe · PHONE SCREENStripe interview questions
  • Find All Points Within a RadiusGoogle · PHONE SCREENGoogle interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions

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[] userResourceTransitionProbabilities(String[][] logs) {
        // Write your code here.
    }
}
Checking account…