Given a list of date ranges r
as input, output or return any ranges not found in r
.
For the sake of this example, input will be in YYYY-MM-DD
format.
Let's say you have three date ranges:
[2019-01-01, 2019-02-01]
[2019-02-02, 2019-04-05]
[2019-06-01, 2019-07-01]
You can see that there is a gap in between 2019-04-05
and 2019-06-01
.
The output will be that gap: [2019-04-06, 2019-05-31]
Rules
- Input and output can be in any reasonable date or collection format, as long as it is consistent.
- Assume the input is not ordered.
- Your date range does not have to be
[latest, earliest]
, but it does have to follow rule 2. - Assume there are no overlapping dates in the input
Test Cases:
Input: [[2019-01-01, 2019-02-01],[2019-02-02, 2019-04-05],[2019-06-01, 2019-07-01]]
Output: [[2019-04-06, 2019-05-31]]
Input: [[2019-01-01, 2019-02-01],[2018-02-02, 2018-04-05],[2019-06-01, 2019-07-01]]
Output: [[2018-04-06, 2018-12-31], [2019-02-02, 2019-05-31]]
Input: [[2019-01-01, 2019-02-01],[2019-02-02, 2019-03-02],[2019-03-03, 2019-07-01]]
Output: []
Input: [[2019-01-01, 2019-02-01], [2019-11-02, 2019-11-20]]
Output: [[2019-02-02, 2019-11-01]]
Input: [[2019-01-01, 2019-02-01],[2019-02-03, 2019-04-05]]
Output: [[2019-02-02, 2019-02-02]]
or [[2019-02-02]]
YYYY-MM-DD
as the current format is both foreign to many people, and made even harder to parse due to using small days-of-month≤12. \$\endgroup\$