Exchange regulatory compliance algorithms at Jane Street and HRT verify that designated market makers maintain continuous quoting presence. You are given a list of candidate quoting intervals intervals where intervals[i] = [s_i, e_i] () and an integer session_end representing the trading session span .
Your Task
Implement consolidate_intervals_and_gaps(intervals: list[list[int]], session_end: int) -> tuple[list[list[int]], list[list[int]]] that returns:
merged: A list of consolidated, mutually disjoint quote coverage intervals sorted by start time.gaps: A list of blackout gap intervals () within the session during which no quote coverage was present.Constraints
Examples
intervals = [[1, 3], [2, 6], [8, 10], [15, 18]]
session_end = 20
# Merged intervals: [[1, 6], [8, 10], [15, 18]]
# Gaps: [[0, 1], [6, 8], [10, 15], [18, 20]]
# Output: ([[1, 6], [8, 10], [15, 18]], [[0, 1], [6, 8], [10, 15], [18, 20]])