Problem: Count Working Days Between Two Dates
Given a start date, an end date (inclusive), and a set of holiday dates, compute the number of working days.
A working day is a date that:
-
is
not
Saturday or Sunday, and
-
is
not
in the provided holiday set.
Input
-
startDate
: string in
YYYY-MM-DD
-
endDate
: string in
YYYY-MM-DD
(guaranteed
endDate >= startDate
)
-
holidays
: list of distinct date strings in
YYYY-MM-DD
Output
-
An integer: number of working days in
[startDate, endDate]
.
Example
-
startDate = 2026-12-24
-
endDate = 2026-12-28
-
holidays = [2026-12-25]
Dates:
-
12/24 Thu (work)
-
12/25 Fri (holiday, not work)
-
12/26 Sat (weekend)
-
12/27 Sun (weekend)
-
12/28 Mon (work)
Output: 2
Constraints (typical)
-
Date range length up to
106
days for a naive iteration; design an approach appropriate to the stated constraints.
-
Holiday count up to
105
.