Minimum Segments
Problem Overview
- Given n intervals (a[i], b[i]) and an integer k, add exactly one segment (a, b) with b − a ≤ k to minimize the number of connected sets.
- Return the minimum number of sets after adding this segment.
- A set is connected if every point from the minimum start to the maximum end is covered by some segment.
- Inputs: arrays a, b, and k; n ≤ 2e5, values ≤ 1e9.
- Snowflake coding interview problem and interview question; context: timeline coverage and range merging.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
