Count Ordered Funnel Conversions Within a Conversion Window
Last updated: November 29, 2026
Quick Overview
Given events (user, timestamp, name) and an ordered list of funnel steps, count how many users reached each step, where steps must happen in order and all within a fixed window measured from the first step.
Mixpanel
November 29, 20260
0
0 solved
Given events (user, timestamp, name) and an ordered list of funnel steps, count how many users reached each step, where steps must happen in order and all within a fixed window measured from the first step.
Funnels are a core Mixpanel report, and the query engine must compute them per user over billions of events. Interviewers check whether you handle the subtle part: a user may start the funnel several times, and the best attempt, not the first, decides how far they got.
What the Interviewer Expects
- Clarify ordering (strictly after vs same timestamp) and that the window starts at step one
- Recognize that a greedy scan from only the first step-one event undercounts
- Use per-step sorted timestamp lists and binary search for the next occurrence
- Report counts per step that are monotonically non-increasing
- Analyze complexity in terms of events and number of step-one attempts
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you support 'any order' funnels or exclusion steps (user must not do X between steps)?
- How would you add a breakdown by a property captured at step one?
- The data is sharded by user across many nodes: how do you combine results?
- How would you cap the cost for a user with millions of step-one events?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: events, steps (ordered names, k of them), window in seconds. A user reaches step j if there exists a step-one event at time s and events for steps 2..j at non-decreasing times all at or ...
High-Level Design
For each user, build a sorted list of timestamps per step name. For every candidate start (each step-one timestamp), greedily take the earliest occurrence of the next step at or after the current time...