easyMath / GeometryPure DSA~15 min
Billing Cycle Day Count
A subscription service prorates the first invoice based on how many days the customer was active in their first billing cycle. Given the start and end day as ISO date strings (same year), return the inclusive number of days between them.
Problem
Given two date strings start and end formatted YYYY-MM-DD, both within the same year and with start <= end, return the number of days from start through end inclusive.
Input
Two strings start and end, each YYYY-MM-DD. Both within the same year (2000 ≤ year ≤ 2100). start ≤ end.
Output
A single integer — inclusive day count.
Constraints
- Both dates are in the same calendar year
- Year is between 2000 and 2100
- Account for leap years (year divisible by 4 except century-not-400)
- Inclusive count: start = end returns 1
Examples
Example 1
Input
start = "2026-03-01", end = "2026-03-05"
Output
5
Mar 1, 2, 3, 4, 5 — inclusive count of 5.
Example 2
Input
start = "2024-02-28", end = "2024-03-01"
Output
3
2024 is a leap year. Days: Feb 28, Feb 29, Mar 1 → 3.