Remove a Blackout Window From a Set of Lightning Deal Periods

Last updated: November 29, 2026

Quick Overview

Given sorted, disjoint half-open deal periods [start, end) and one blackout period, return the remaining deal time after cutting the blackout out of every period.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given sorted, disjoint half-open deal periods [start, end) and one blackout period, return the remaining deal time after cutting the blackout out of every period.

An Amazon technical screen interval question based on pausing Lightning Deals during a site incident. The interviewer checks clean case analysis for partial overlap on either side, full containment and no overlap, using half-open intervals consistently.

What the Interviewer Expects
  • Confirm the half-open convention and what zero-length pieces mean
  • Handle the no-overlap case by copying the period
  • Keep the left remainder when a period starts before the blackout
  • Keep the right remainder when a period ends after the blackout
  • Return results in sorted order
Key Topics to Cover
Intervals
Interval Subtraction
Case Analysis
Half-Open Ranges
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 subtract a list of blackout windows efficiently?
  • What if periods are stored in an interval tree and queried by time?
  • How do you compute total remaining deal minutes in one pass?
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: periods, sorted disjoint [a, b) pairs; blackout = [x, y). Output: sorted disjoint list representing periods minus blackout, with no empty intervals....

High-Level Design

Handle each period independently, since subtraction distributes over a union.

  • If b <= x or a >= y, there is no overlap: keep [a, b).
  • Otherwise, the left remainder [a, x) survives if `a < ...

Submit Your Answer
Markdown supported