Compute First Response Time per Support Conversation From Event Logs
Last updated: November 29, 2026
Quick Overview
Given an unordered log of (conversation_id, timestamp, actor) events where actor is user, ai or human, return the first response time for each conversation (time from the first user message to the first non-user message after it) and the median across conversations.
Decagon
November 29, 20260
0
0 solved
Given an unordered log of (conversation_id, timestamp, actor) events where actor is user, ai or human, return the first response time for each conversation (time from the first user message to the first non-user message after it) and the median across conversations.
Speed to first reply is one of the headline numbers a Decagon customer looks at when comparing its AI agent with a human queue, so a warm-up built on raw conversation events fits a first screen. The interviewer checks clean grouping and ordering logic, and whether you pin down the definition before coding instead of guessing.
What the Interviewer Expects
- Clarifies what counts as a response and what happens when the agent speaks first
- Sorts or groups by conversation and timestamp rather than trusting input order
- Stops scanning a conversation once its response is found
- Excludes conversations with no response instead of reporting zero
- Computes the median correctly for even and empty inputs
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 report the 90th percentile per customer per day over billions of events?
- A proactive greeting from the agent arrives before the user types. Should it count?
- How would you compute this incrementally as events stream in out of order?
- How would you split the metric between AI replies and human replies after a handoff?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: a list of (conversation_id, ts, actor) tuples in any order. For each conversation, find the first user message, then the first ai or human message strictly after it in time order. The d...
High-Level Design
Sort events by (conversation_id, ts) so each conversation is contiguous and chronological. Walk once, keeping first_user[conv] and result[conv]. When a conversation already has a result, skip it...