Your question is Find Missing Subranges. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Collective Health processes covered service-day ranges for a member. Given inclusive integer intervals that are already covered, return all inclusive ranges not covered within an absolute minimum and maximum value.
Intervals may be unsorted, overlapping, adjacent, or fully contained within another interval. The output must be sorted by range start, non-overlapping, and must not include values outside [minimum, maximum]. Each output range should be represented as a two-element list [start, end].
Implement missing_ranges(ranges, minimum, maximum), where ranges is a list of inclusive integer intervals and minimum <= maximum. Return a list of inclusive integer intervals representing the complement of the union of ranges within [minimum, maximum].
All input intervals are valid and lie within the absolute bounds.
def missing_ranges(ranges, minimum, maximum):