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
Coding & Algorithms
Software Engineer
Decagon
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
sorting
hash maps
event logs
median
support metrics
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions