Maintenance Window Problem
Maintenance Window Problem — ExecCode Medium DSA Practice
Solve the Maintenance Window problem on ExecCode. Free online medium DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
A company's server is available from time 0 to time S. During this period, N maintenance tasks are scheduled, and each task occupies the server on the interval [start, end]. The intervals are given in increasing order of start time and do not overlap. Decide whether there is one continuous free period of at least K minutes. Return YES if such a period exists, and NO otherwise. Return whether a free gap of length K exists. You are given: S — S K — K meetings — meetings Return whether a free gap of length K exists. Copied from OA Lab Part 1.
Examples
Input {'S': 20, 'K': 3, 'meetings': [[2, 5], [8, 10], [14, 17]]}; Output YES. Input {'S': 20, 'K': 5, 'meetings': [[2, 5], [8, 10], [14, 17]]}; Output NO. Input {'S': 20, 'K': 4, 'meetings': [[2, 5], [8, 10], [14, 17]]}; Output YES
Constraints
Follow the statement. Use a 64-bit integer when values can overflow.
Practice Maintenance Window free on ExecCode. Browse DSA problems, topic map, and placement guides.