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]exposures = [[1, 3], [2, 4], [6, 8]]Output2WhyThe first two intervals overlap and merge into one window, while `[6, 8]` forms a second window.exposures = [[5, 5], [6, 7], [7, 9]]Output1WhyBecause adjacency also counts as mergeable, all three intervals combine into a single window `[5, 9]`.exposures = [[1, 2], [4, 5], [7, 8]]Output3WhyNone of the intervals overlap or touch, so each requires its own remediation window.1 <= len(exposures) <= 10^50 <= start_time <= end_time <= 10^9Each exposure is an inclusive interval [start_time, end_time]Intervals should be merged if they overlap or are adjacentdef count_remediation_windows(exposures):