Bill Peak Concurrent Seats From Seat Assignment Intervals

Last updated: November 29, 2026

Quick Overview

Given seat assignments as half-open minute intervals `[start, end)` and a billing period, clip each assignment to the period and return the peak number of concurrently assigned seats, the first minute that peak is reached, and total seat-minutes used.

Stripe
Coding & Algorithms
Software Engineer
Stripe
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given seat assignments as half-open minute intervals `[start, end)` and a billing period, clip each assignment to the period and return the peak number of concurrently assigned seats, the first minute that peak is reached, and total seat-minutes used.

Seat-based SaaS merchants on Stripe Billing often bill on peak concurrent seats or on seat-time, so turning raw assignment history into a billable quantity is a realistic metering task. The interviewer checks that you reach for a sweep line, handle touching intervals correctly and clip to the billing period before counting.

What the Interviewer Expects
  • Clip intervals to the billing period and drop the ones that fall outside
  • Use a sweep over start and end events instead of scanning every minute
  • Order ends before starts at the same timestamp so back-to-back seats do not overlap
  • Compute seat-minutes from the clipped lengths, not from the raw intervals
  • Explain the tie-break and the half-open convention out loud
Key Topics to Cover
sweep line
intervals
sorting
usage-based billing
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 usage per day instead of for the whole period?
  • What if intervals arrive as a stream of assign and release events with some releases missing?
  • How would you bill the average seat count weighted by time instead of the peak?
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

Each assignment is [start, end) in integer minutes; end may be past the period. The billing period is [ps, pe). Output (peak, peak_start, seat_minutes). If no assignment overlaps the period, r...

High-Level Design

Clip each interval to [max(s, ps), min(e, pe)) and skip empty results. Add its length to seat-minutes and emit (s, +1) and (e, -1) events. Sorting tuples puts -1 before +1 at the same time, ...


Submit Your Answer
Markdown supported