At AcmeCloud, a developer keeps committing API keys to a public repository. You need to build a system that detects exposed secrets and groups nearby exposures into the smallest number of remediation windows.
Given a list of commit timestamps and a list of detected secret exposures, where each exposure has a start_time and end_time, return the minimum number of non-overlapping remediation windows needed after merging all overlapping or adjacent exposure intervals.
Implement a function that takes exposures, a list of pairs [start_time, end_time], and returns an integer.
List[List[int]] where each pair represents an inclusive interval.int representing the number of merged remediation windows.Two intervals should be merged if they overlap or if one ends exactly when the next begins.
Example 1
Input: exposures = [[1, 3], [2, 4], [6, 8]]
Output: 2
Explanation: [1, 3] and [2, 4] merge into [1, 4], while [6, 8] remains separate.
Example 2
Input: exposures = [[5, 5], [6, 7], [7, 9]]
Output: 1
Explanation: The intervals are adjacent or overlapping, so they merge into one remediation window [5, 9].
1 <= len(exposures) <= 10^50 <= start_time <= end_time <= 10^9[start_time, end_time]