PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Whatnot

Count User Journey Prefixes

Last updated: Apr 6, 2026

Quick Overview

This question evaluates the ability to reconstruct per-user action sequences from timestamped logs, aggregate and count path prefixes, and apply data-structure and algorithmic reasoning within the Coding & Algorithms domain.

  • easy
  • Whatnot
  • Coding & Algorithms
  • Software Engineer

Count User Journey Prefixes

Company: Whatnot

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

You are given a list of user activity logs. Each log record has the form `[user_id, timestamp, action]`. Example input: ```text logs = [ [100, 1, "A"], [101, 2, "A"], [100, 3, "B"], [102, 4, "B"], [101, 5, "C"], [100, 6, "C"], [103, 7, "A"], [103, 8, "B"] ] ``` For each user, reconstruct that user's journey by ordering the actions by `timestamp`. Then aggregate all users' journeys and compute the count of every path prefix. Using the example above, the reconstructed journeys are: - `100 -> A, B, C` - `101 -> A, C` - `102 -> B` - `103 -> A, B` The aggregated prefix counts are: ```text A (3) B (2) C (1) C (1) B (1) ``` Explanation: - `A` appears as the first action for 3 users. - `A -> B` appears for 2 users. - `A -> B -> C` appears for 1 user. - `A -> C` appears for 1 user. - `B` appears as the first action for 1 user. Return the aggregated prefix counts in any reasonable structured format, such as a trie, nested map, or a list of prefixes with counts. Discuss the time and space complexity of your approach, and whether the trie can be updated while scanning the logs instead of first building full per-user action lists.

Quick Answer: This question evaluates the ability to reconstruct per-user action sequences from timestamped logs, aggregate and count path prefixes, and apply data-structure and algorithmic reasoning within the Coding & Algorithms domain.

Related Interview Questions

  • Build a Tic-Tac-Toe App - Whatnot (medium)
  • Build User Journey Path Summary - Whatnot (hard)
Whatnot logo
Whatnot
Apr 1, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
4
0
Loading...

You are given a list of user activity logs. Each log record has the form [user_id, timestamp, action].

Example input:

logs = [
  [100, 1, "A"],
  [101, 2, "A"],
  [100, 3, "B"],
  [102, 4, "B"],
  [101, 5, "C"],
  [100, 6, "C"],
  [103, 7, "A"],
  [103, 8, "B"]
]

For each user, reconstruct that user's journey by ordering the actions by timestamp. Then aggregate all users' journeys and compute the count of every path prefix.

Using the example above, the reconstructed journeys are:

  • 100 -> A, B, C
  • 101 -> A, C
  • 102 -> B
  • 103 -> A, B

The aggregated prefix counts are:

A (3)
  B (2)
    C (1)
  C (1)
B (1)

Explanation:

  • A appears as the first action for 3 users.
  • A -> B appears for 2 users.
  • A -> B -> C appears for 1 user.
  • A -> C appears for 1 user.
  • B appears as the first action for 1 user.

Return the aggregated prefix counts in any reasonable structured format, such as a trie, nested map, or a list of prefixes with counts.

Discuss the time and space complexity of your approach, and whether the trie can be updated while scanning the logs instead of first building full per-user action lists.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Whatnot•More Software Engineer•Whatnot Software Engineer•Whatnot Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.