FastPrepUser Journey Paths from a Log Stream
Problems/User Journey Paths from a Log Stream

User Journey Paths from a Log Stream

WhatNot logoWhatNot● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an experienced engineer's phone screen at Whatnot in mid 2026, as the follow-up to the user journey question already on this site. Once the batch version worked, the logs were to come in as a stream instead of a full list.

The report does not say how the stream is fed in or when the tree is read. Here, the logs arrive in time order mixed with summary requests, and each request returns the tree built so far in the same line format as the first part.

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

A platform records what its users do, but the logs now arrive one at a time while the platform keeps running. You are given the array events in arrival order. Each event is either a log "user_id time action" or the word "SUMMARY".

For every SUMMARY, produce the journey tree of all logs that arrived before it, as an array of text lines. Return one array of lines per SUMMARY, in order.

The journey tree works like this:

  • A user's journey is that user's actions sorted by time, smallest first. Logs arrive in time order, so this is also the order in which the user's logs arrive.
  • Each journey is put into one tree. Each node is one action, and a path from the top of the tree is a start of a journey. A repeated action is a new step: in A -> B -> B the second B is a child of the first B.
  • Each node has a count: the number of different users whose journey so far follows that exact path down to the node.

Each summary lists the tree, without its top, as lines:

  • Each line is ACTION (count).
  • The first actions of the journeys are at depth 0 and have no prefix. A node at depth d (1 or more) starts with 2*d spaces and then -> . So depth 1 starts with -> (two spaces) and depth 2 with -> (four spaces).
  • Print a node's line first, then everything below it, before the next sibling. Siblings go in plain character order of the action, so A comes before B, and B comes before a.
  • A summary before any log is an empty array.

Function

journeySummaries(events: String[]) → List<List<String>>

Examples

Example 1

events = ["1 10 A","2 12 A","SUMMARY","1 15 B","SUMMARY"]return = [["A (2)"],["A (2)","  -> B (1)"]]

At the first SUMMARY, users 1 and 2 have each done A, so the tree is the single line A (2). Then user 1 does B. At the second SUMMARY, B hangs under A with a count of 1.

Example 2

events = ["SUMMARY","5 1 home","SUMMARY"]return = [[],["home (1)"]]

The first SUMMARY comes before any log, so its tree is empty. After user 5 does home, the tree has one line.

Example 3

events = ["1 1 A","1 2 A","2 3 b","2 4 B","SUMMARY"]return = [["A (1)","  -> A (1)","b (1)","  -> B (1)"]]

User 1 does A twice, so the second A is a child of the first. User 2 does b then B. At the top level A comes before b, because uppercase letters come before lowercase ones in character order.

Example 4

events = ["1 5 A","2 5 A","1 6 B","2 7 C","1 8 C","SUMMARY","2 9 B","SUMMARY"]return = [["A (2)","  -> B (1)","    -> C (1)","  -> C (1)"],["A (2)","  -> B (1)","    -> C (1)","  -> C (1)","    -> B (1)"]]

Users 1 and 2 both start with A at time 5. Before the first SUMMARY, user 1 has gone A, B, C and user 2 has gone A, C. After it, user 2 does B, which goes under that user's C, not at the top. Each new log continues the journey of its own user.

Constraints

  • 1 <= events.length <= 10^4
  • Each event is "SUMMARY" or a log of three fields separated by single spaces: an integer user_id, an integer time, and an action. At least one event is "SUMMARY".
  • user_id and time are between 0 and 10^9, written without leading zeros.
  • Each action has 1 to 10 letters or digits.
  • Logs arrive in time order: each log's time is at least the time of the log before it. Two logs of the same user never have the same time.
  • Each user has at most 50 logs.
  • All summaries together have at most 2 * 10^4 lines.

More WhatNot Phone Screen questions

  • Adjacent Pair and Run RemovalPHONE SCREEN · Seen Nov 2026
  • Merge Sorted Squares of Two ArraysPHONE SCREEN · Seen Nov 2026
  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Knight Dialer SequencesPHONE SCREEN · Seen Oct 2026
  • Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
  • Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
  • Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
  • Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Domain Weight CalculationAmazon · ONSITE INTERVIEW
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • Account Roles With Parent-User InheritanceStripe · PHONE SCREENStripe interview questions
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Nested Substitutions with Cycle DetectionKikoff · PHONE SCREENKikoff interview questions
  • Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
  • Validate and Resolve Evaluation ChainsPlaid · PHONE SCREEN · ONSITE INTERVIEWPlaid interview questions
  • Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
  • Root of the Largest TreeGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions

WhatNot interview experiences

  • Whatnot SWE New Grad Second Technical Interview: 8 Experiences
  • Whatnot interviews · October 2026
  • Whatnot Experienced SWE Phone Screen Questions: 2 Experiences
  • Whatnot SWE Interview Questions: 6 Experiences
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public List<List<String>> journeySummaries(String[] events) {
        
    }
}
Checking account…