Weekly Deployment Windows: Subtract Freeze Periods, Convert Time Zones, Return Next k

Quick Overview

Given weekly allowed and freeze windows expressed in minutes of the week, compute the intervals in which deployments may run. A second part adds a time zone offset, the current UTC time, a lead time and a limit of k returned windows, testing interval merging and subtraction, week wrap-around and careful time zone arithmetic.

Weekly Deployment Windows: Subtract Freeze Periods, Convert Time Zones, Return Next k

Company: Stripe

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Online Assessment

Build a deployment window scheduler. A team describes when deployments may happen with two lists of weekly intervals, both measured in minutes from the start of the week: `allowed` windows, when deployments are permitted, and `freeze` windows, when they are forbidden. A deployment may happen only inside an allowed window and outside every freeze window. The exact input format was not reported; the illustration below is an assumption to make the parts concrete. ```text one week = 7 * 24 * 60 = 10080 minutes; minute 0 = start of the week (illustrative) allowed = [[540, 1020], [600, 720], [1980, 2460]] # day 1 09:00-17:00, day 1 10:00-12:00, day 2 09:00-17:00 freeze = [[720, 780], [2400, 2700]] # day 1 12:00-13:00, day 2 16:00-21:00 ``` ### Clarifying Questions - Are intervals half-open, `[start, end)`, or closed, and are all values whole minutes? - Can windows of the same kind overlap or touch, and can a window wrap past the end of the week into its start? - Which day and time is minute 0? - In which clock are the allowed and the freeze windows written: the team's local time, UTC, or one of each? ### Part 1 — Deployable windows in one week Return the deployable windows for the week: the union of the allowed windows minus the union of the freeze windows, as sorted, non-overlapping intervals with empty pieces removed. ```hint Normalize first Put each list into a sorted, non-overlapping form before combining them; after that, one pass over both lists is enough. ``` #### What This Part Should Cover - Merging overlapping and touching windows - Subtraction when a freeze covers a whole allowed window, splits one, or spans several - Sorted, disjoint output, edge cases such as empty lists and zero-length windows, and the complexity ### Part 2 — Time zone, current time, lead time and the next k windows The windows are now written in the team's local time. You are also given the local time zone's offset from UTC, the current time `utc_now`, a lead time in minutes, and a limit `k`. Return at most `k` upcoming deployment windows in UTC, earliest first, taking the lead time into account: no deployment may start earlier than the lead time after `utc_now`. ```hint One clock Convert everything to UTC before comparing it with the current time, and look closely at windows that the shift pushes across the boundary between two weeks. ``` #### Clarifying Questions for this Part - What is the sign convention of the offset: is local time equal to UTC plus the offset? - Is `utc_now` a minute of the week or an absolute timestamp, and in which form should windows be returned? - If a window is already open at `utc_now` plus the lead time, is its remainder returned, or is the window skipped? - If fewer than `k` windows remain this week, does the search continue into the following weeks? - Is a window that runs across the end of one week into the next returned as one window or two? #### What This Part Should Cover - Correct local-to-UTC conversion, including windows pushed across the week boundary - Applying the current time and the lead time, and repeating the weekly pattern to find enough windows - Returning at most `k` windows in order, and the cost of the search ### What a Strong Answer Covers - Settles the interval convention and the meaning of the offset, the current time and the lead time before coding - Correct merge and subtraction, including touching, nested and spanning windows - Correct time zone arithmetic with wrap-around at the week boundary, for offsets of both signs - Small, separately tested functions, with the complexity of each stated - Tests at the boundaries: windows ending at minute 10,080, the lead time landing inside a window, fewer than `k` windows in a week ### Follow-up Questions - The team's time zone observes daylight saving time. What breaks with a fixed offset, and how do you fix it? - A deployment takes a fixed number of minutes. How do you return only windows long enough to finish one? - Several teams in different time zones must all be inside an allowed window. How do you compute the common windows? - Some freezes become one-off absolute dates, such as a holiday, rather than weekly intervals. What changes?

Overview: Given weekly allowed and freeze windows expressed in minutes of the week, compute the intervals in which deployments may run. A second part adds a time zone offset, the current UTC time, a lead time and a limit of k returned windows, testing interval merging and subtraction, week wrap-around and careful time zone arithmetic.

Stripe logo
Stripe
Sep 19, 2026
mediumSoftware EngineerOnline AssessmentSoftware Engineering Fundamentals
1
0

Build a deployment window scheduler. A team describes when deployments may happen with two lists of weekly intervals, both measured in minutes from the start of the week: allowed windows, when deployments are permitted, and freeze windows, when they are forbidden. A deployment may happen only inside an allowed window and outside every freeze window.

The exact input format was not reported; the illustration below is an assumption to make the parts concrete.

one week = 7 * 24 * 60 = 10080 minutes; minute 0 = start of the week        (illustrative)

allowed = [[540, 1020], [600, 720], [1980, 2460]]   # day 1 09:00-17:00, day 1 10:00-12:00, day 2 09:00-17:00
freeze  = [[720, 780], [2400, 2700]]                # day 1 12:00-13:00, day 2 16:00-21:00

Clarifying Questions Guidance

  • Are intervals half-open, [start, end) , or closed, and are all values whole minutes?
  • Can windows of the same kind overlap or touch, and can a window wrap past the end of the week into its start?
  • Which day and time is minute 0?
  • In which clock are the allowed and the freeze windows written: the team's local time, UTC, or one of each?

Part 1 — Deployable windows in one week

Return the deployable windows for the week: the union of the allowed windows minus the union of the freeze windows, as sorted, non-overlapping intervals with empty pieces removed.

What This Part Should Cover Guidance

  • Merging overlapping and touching windows
  • Subtraction when a freeze covers a whole allowed window, splits one, or spans several
  • Sorted, disjoint output, edge cases such as empty lists and zero-length windows, and the complexity

Part 2 — Time zone, current time, lead time and the next k windows

The windows are now written in the team's local time. You are also given the local time zone's offset from UTC, the current time utc_now, a lead time in minutes, and a limit k. Return at most k upcoming deployment windows in UTC, earliest first, taking the lead time into account: no deployment may start earlier than the lead time after utc_now.

Clarifying Questions for this Part Guidance

  • What is the sign convention of the offset: is local time equal to UTC plus the offset?
  • Is utc_now a minute of the week or an absolute timestamp, and in which form should windows be returned?
  • If a window is already open at utc_now plus the lead time, is its remainder returned, or is the window skipped?
  • If fewer than k windows remain this week, does the search continue into the following weeks?
  • Is a window that runs across the end of one week into the next returned as one window or two?

What This Part Should Cover Guidance

  • Correct local-to-UTC conversion, including windows pushed across the week boundary
  • Applying the current time and the lead time, and repeating the weekly pattern to find enough windows
  • Returning at most k windows in order, and the cost of the search

What a Strong Answer Covers Guidance

  • Settles the interval convention and the meaning of the offset, the current time and the lead time before coding
  • Correct merge and subtraction, including touching, nested and spanning windows
  • Correct time zone arithmetic with wrap-around at the week boundary, for offsets of both signs
  • Small, separately tested functions, with the complexity of each stated
  • Tests at the boundaries: windows ending at minute 10,080, the lead time landing inside a window, fewer than k windows in a week

Follow-up Questions Guidance

  • The team's time zone observes daylight saving time. What breaks with a fixed offset, and how do you fix it?
  • A deployment takes a fixed number of minutes. How do you return only windows long enough to finish one?
  • Several teams in different time zones must all be inside an allowed window. How do you compute the common windows?
  • Some freezes become one-off absolute dates, such as a holiday, rather than weekly intervals. What changes?