Compute Per-Customer Billable Minutes From Call Records

Last updated: November 29, 2026

Quick Overview

Given a list of call records (customer_id, start_sec, end_sec), return each customer's billable minutes where every call is billed per started minute and calls at or below a minimum connected duration are free.

Retell AI
Coding & Algorithms
Software Engineer
Retell AI
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of call records (customer_id, start_sec, end_sec), return each customer's billable minutes where every call is billed per started minute and calls at or below a minimum connected duration are free.

Retell bills voice agents by the minute, so a warm-up screen in this style checks that you can turn raw call records into money without off-by-one mistakes. The interviewer is looking for clean rounding with integers, careful handling of zero-length and failed calls, and a deterministic output.

What the Interviewer Expects
  • Clarify the rounding rule (per started minute, per call, not on the summed total)
  • Use integer ceiling division instead of floats
  • Skip zero-length and below-threshold calls explicitly
  • Return a stable, sorted result
  • State O(n) time
Key Topics to Cover
ceiling division
aggregation
hash maps
billing edge cases
idempotency
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 bill per second with a 60 second minimum instead?
  • What changes if a single call can span a monthly invoice boundary?
  • How would you make this idempotent when the same call record is delivered twice?
  • How would you handle negative durations caused by clock skew between services?
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: list of (customer_id, start_sec, end_sec). Each call is rounded up to whole minutes on its own (a 61 second call is 2 minutes). Calls with duration <= min_seconds are not billed (this cover...

High-Level Design

One pass over the records, accumulate into a dictionary. Rounding happens per call before summing, because summing seconds first would undercharge (two 61 second calls are 4 billable minutes, not 3). ...


Submit Your Answer
Markdown supported

Related Questions