Merge Overlapping Do Not Disturb Windows Across Focus Modes

Last updated: November 29, 2026

Quick Overview

Each Focus mode on an iPhone contributes silence windows as [start, end) minute pairs within a day. Merge all windows into the minimal sorted list of non-overlapping intervals, where touching intervals such as [60, 120) and [120, 180) are merged.

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

0

0

0 solved


Each Focus mode on an iPhone contributes silence windows as [start, end) minute pairs within a day. Merge all windows into the minimal sorted list of non-overlapping intervals, where touching intervals such as [60, 120) and [120, 180) are merged.

A common Apple phone-screen warm-up dressed in iOS Focus terms. The interviewer checks sorting by start, correct overlap condition for half-open intervals, and that you do not mutate the caller's data unexpectedly.

What the Interviewer Expects
  • Sort intervals by start time
  • Merge when the next start is at most the current end
  • Use half-open semantics consistently
  • Avoid mutating input lists
  • State O(n log n) complexity
Key Topics to Cover
intervals
sorting
merging
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
  • Windows can cross midnight, such as [1380, 420); how do you handle them?
  • Given the merged list, answer 'is the phone silenced at minute t' quickly.
  • Windows are added one at a time from different Focus modes; keep the merged list updated.
  • Compute total silenced minutes per day.
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 [start, end) pairs with 0 <= start < end <= 1440. Output: merged, sorted, non-overlapping intervals; adjacency counts as overlap because the user experiences continuous silence. E...

High-Level Design

Sort by start. Walk the sorted list keeping the last merged interval. If the next start is less than or equal to the last end, extend the end to the max of both ends; otherwise append a new interval. ...


Submit Your Answer
Markdown supported