← Whatnot Interview Insights

Whatnot·Software Engineer·Technical Phone Screen·Intermediate

IntermediateRejected
Jun 2026Remote

Summary

Whatnot phone coding round for a software engineer role, 60 minutes, one problem the whole time. I understood the concept well enough but couldn't finish the implementation and got rejected.

Questions Asked (1)

Q1

Given a log of user actions with timestamps (user_id, time, action), build a summary of unique action paths and how many distinct users followed each path. Output as an indented tree. Logs may arrive out of order.

Algorithms & Data Structures
Author's notes

I knew the shape of the solution pretty fast: group by user, sort by time, build a trie, DFS print with indentation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, sort the log by user_id and timestamp to reconstruct each user's action sequence. Then, for each user, build the path string (e.g., 'login > view > purchase') and count how many distinct users have each path. Finally, insert these paths into a trie and output the trie as an indented tree with user counts at each node.

Pro tip: Clarify whether the path should be based on the full sequence of actions or only unique actions in order, and whether timestamps with equal values need a tie-breaker. Also, mention that you'd handle out-of-order logs by sorting, which is O(n log n), and that a trie naturally aggregates counts and supports the tree output.

1. Clarify requirements and edge cases

Ask about the definition of a 'path' (full sequence vs. unique actions), how to handle ties in timestamps, and whether the output should include counts at each node or only leaves. Also confirm if users with no actions should be ignored.

2. Sort and group logs by user

Sort the log entries by user_id and then by timestamp to reconstruct each user's action sequence. If timestamps are equal, use a stable sort or an additional tie-breaker like action name.

3. Build path strings and count distinct users

For each user, concatenate their actions in order to form a path string (e.g., 'A>B>C'). Use a hash map to count how many distinct users have each path.

4. Insert paths into a trie

Insert each unique path into a trie, where each node represents an action and stores the count of users whose path passes through that node. This aggregates counts for shared prefixes.

5. Output the trie as an indented tree

Perform a depth-first traversal of the trie, printing each node with indentation proportional to its depth and appending the user count. Ensure the output is sorted alphabetically or by count for consistency.

Key Points to Mention

  • Sorting is necessary to handle out-of-order logs; time complexity O(n log n) due to sorting.
  • Using a hash map to count distinct users per path ensures we don't double-count the same user.
  • A trie (prefix tree) efficiently aggregates counts for shared prefixes and naturally supports tree output.
  • Edge cases: empty log, single user, multiple users with identical paths, timestamps with ties.
  • Space complexity: O(total number of actions) for the trie and hash map.
  • Output format: indentation should reflect depth, and counts should be shown at each node (or only leaves, depending on requirement).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.