Interview Questions/Coding/Shared Onsite Window

Shared Onsite Window

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Shared Onsite Window

A hiring team records the onsite availability window for every interviewer during the same non-leap year. Each date is written in MM-DD format, and both the arrival date and leave date are inclusive. The team wants to know how many calendar days exist where every interviewer is present at the same time. If the availability windows do not overlap, the answer is 0. Input Format: You are given arrays arrivals and leaves of equal length. Output Format: Return the number of days common to all interviewer availability windows.

Examples

Example 1
Input:
arrivals = ["08-15", "08-16"]
leaves = ["08-18", "08-19"]
Output:
3

Explanation: The latest arrival day is day 228, and the earliest leaving day is day 230. Their inclusive overlap is 3 day(s), so the output is 3.

Approach hint

Look for the state that actually matters after each operation.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp