Stripe's online assessment really required a huge amount of code, and the problem was both tedious and long.
The problem gives a global UTC timeline covering the 10,080 minutes in one week, along with deployment rules defined in local time. The rules mark deployment as allowed or frozen and each has a corresponding time-zone offset.
The task is to find and return the first K qualifying UTC deployment windows.
The effective start cannot be earlier than the first deployable time:
earliest_start = utc_now + lead_time
For minimum duration, a window's continuous valid period must be at least min_duration.
The central tricky point is mapping time zones across week boundaries. After computing UTC = Local - Offset, the result may be negative, meaning the previous week, or greater than 10,080, meaning the next week. Taking the result directly modulo the range [0, 10079] can break a continuous interval apart. The suggested approach is to expand the global marking array to three times its size, representing a range such as [-10080, 20160], and use shifted indices to avoid going out of bounds.
There is also greedy splitting of long intervals. When a continuous allowed interval is much longer than min_duration, you cannot return the whole long interval as one window. You need to step through it with a while loop and split it into independent windows of length min_duration until you have K windows.
I only saw two parts of the problem. There were 11 test cases in total. Part 1 passed completely. Part 2 had six cases, and one case failed, so my final score was 10 out of 11.
I do not know whether there will be another round.
This felt like a new problem. I had not seen it in prior interview reports. LeetCode 1229 and 56 are also worth reviewing as related variants.
Discussion
Loading comments…