User Journey Paths
Reported by candidates from Whatnot's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Whatnot's May 2026 OA asked you to build a Trie that summarizes user action sequences. You're given unsorted logs with user_id, timestamp, and action. Group each user's logs by time, then insert their action sequence into a tree where each node tracks how many distinct users passed through that prefix. The output is an indented tree with lexicographic ordering and count annotations. This is a trie construction problem dressed as a user journey analyzer. StealthCoder will have your back if the tree traversal or output formatting logic blanks you during the live OA.
The problem
Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem. Problem User Journey Paths (Action Log Trie Summary) You are given action logs emitted by a platform. Each log entry is a tuple: (user_id, time, action). Build a path tree (Trie-like summary) of users' journeys: For each user, sort their logs by time ascending to obtain that user's action sequence. Insert each user's sequence into a tree. Each node represents an action; a path from the root represents an action-prefix. Each node stores a count = the number of distinct users whose journey reached that node via that prefix. Input List[Tuple[int, int, str]] log entries (user_id, time, action). Output Return an indented string representation of the tree: Do not print the root. Each line: ACTION (count). Children are indented by two spaces and prefixed with ->. For deterministic output, print siblings in lexicographic order by action. Notes / Edge cases Logs can be unordered: group by user and sort by time. Each user contributes +1 to every prefix node along their path. Repeated actions are distinct steps (e.g., A -> B -> B is valid; the second B is a child of the first B). Empty input ⇒ empty output string. Single user / single action ⇒ single node. Example Input logs: 100 1000 A 300 1150 A 200 1200 B 100 1200 B 100 1300 C 200 1400 A 300 1500 B 300 1550 B 100 1560 D Per-user sequences: user 100: A -> B -> C -> D user 200: B -> A user 300: A -> B -> B Expected output: A (2) -> B (2) -> B (1) -> C (1) -> D (1) B (1) -> A (1) Tests Use the 5 test cases described in the prompt (main example, empty, single action, identical paths, out-of-order logs). Example Input 100 1000 A 300 1150 A 200 1200 B 100 1200 B 100 1300 C 200 1400 A 300 1500 B 300 1550 B 100 1560 D Output A (2) -> B (2) -> B (1) -> C (1) -> D (1) B (1) -> A (1) Function Description Complete solveUserJourneyPaths. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters. The returned string array must match the expected standard output lines for the sample input. Use the limits and requirements stated in the prompt.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The core trick: this isn't about pathfinding or searching. It's about building a standard Trie and annotating each node with the count of users who reached it. Parse the input, group logs by user_id, sort each user's logs by timestamp, then walk each sorted sequence through the Trie, incrementing counts at every node you visit. The catch is output formatting: you must do a depth-first traversal, print siblings in lexicographic order, indent by two spaces, and format each line as 'ACTION (count)'. Off-by-one errors on counts and missing children are common. The pattern is trie construction with aggregation. If you blank on the tree structure or traversal during the OA, StealthCoder will show you the exact node layout and print order.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill User Journey Paths cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderYou've seen the question.
Make sure you actually pass Whatnot's OA.
Whatnot reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
User Journey Paths FAQ
Do I need to store the full tree in memory or can I stream the output?+
You must build the full tree first. Each user's journey increments counts along the entire path. You can't print until you've processed all users, because later users might extend earlier prefixes. Build the tree, then traverse it depth-first for output.
What if two users have identical action sequences?+
Every node on that path gets +1 count per user. So if users 100 and 200 both do A -> B, the root's A child has count 2, and A's B child has count 2. Each traversal increments independently.
How do I handle repeated actions like A -> B -> B?+
The second B is a separate child node under the first B. Trie nodes are keyed by action string, not uniqueness. So you create a chain: root -> A -> B -> B. Each node in that chain has its own count.
Do I sort the entire log list before grouping by user?+
No. Group by user_id first, then sort each user's group by timestamp. Different users' timestamps don't matter relative to each other, only within each user's journey.
What does 'lexicographic order' mean for the output?+
Print siblings (children of the same parent node) in alphabetical order by action string. So if a node has children B and A, print A first, then B. Use standard string comparison.