Merge Overlapping Maintenance Windows for an AWS Region

Last updated: November 29, 2026

Quick Overview

Given a list of scheduled maintenance windows as [start, end] minute pairs for services in one AWS Region, merge every overlapping or touching window and return the consolidated list sorted by start.

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

0

0

0 solved


Given a list of scheduled maintenance windows as [start, end] minute pairs for services in one AWS Region, merge every overlapping or touching window and return the consolidated list sorted by start.

A standard Amazon phone-screen interval question framed around building a single customer-facing maintenance calendar from many teams' schedules. The interviewer checks sorting by start, a single merge pass, and a precise rule for whether touching windows merge.

What the Interviewer Expects
  • Ask whether [1, 3] and [3, 5] should merge
  • Sort by start time
  • Extend the last merged window or start a new one
  • Avoid mutating the caller's input unexpectedly
  • State O(n log n) time
Key Topics to Cover
Intervals
Sorting
Merging
Arrays
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 merge windows that arrive one at a time in real time?
  • What if the input is already sorted per team but there are many teams?
  • How would you also report which services are affected in each merged window?
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 [start, end] integer pairs with start <= end, unsorted, possibly empty. Output: list of disjoint [start, end] pairs covering exactly the union, sorted by start. Windows that touch...

High-Level Design

After sorting by start, any window that overlaps the current merged block must come right after it in the order, because a later start cannot jump back in front. So scan once:

  • If the next window st...

Submit Your Answer
Markdown supported