Deployment Window Freezes
MediumIntervals ยท Stripe
Given windows, the intervals when deployments are allowed, and freezes, the intervals when they are not, return the minutes of the week that lie in some window and in no freeze.
Every interval [a, b] covers the minutes from a up to but not including b, counted from the start of the week (10080 minutes in all). A freeze with a > b wraps past the end of the week and covers [a, 10080) and [0, b).
Return the result as sorted [start, end] intervals, with no two overlapping or touching.
Example 1
- Input:
- windows = [[0, 600], [500, 1500], [3000, 3600]], freezes = [[700, 800], [1400, 3100]]
- Output:
- [[0, 700], [800, 1400], [3100, 3600]]
- Explanation
- The first two windows overlap into [0, 1500], which the freezes cut apart. The second freeze also removes the start of the last window.
Example 2
- Input:
- windows = [[0, 300], [9900, 10080]], freezes = [[10000, 100]]
- Output:
- [[100, 300], [9900, 10000]]
- Explanation
- The freeze wraps: it covers [10000, 10080) and [0, 100).
Example 3
- Input:
- windows = [[100, 200], [200, 300]], freezes = [[300, 400]]
- Output:
- [[100, 300]]
Constraints
0 <= windows.length <= 2000and0 <= freezes.length <= 20000 <= a < b <= 10080for every window; windows may overlap and come in any order0 <= a < 10080and0 <= b <= 10080witha != bfor every freeze