Skip to main content

ranges_to_rle_counts

def ranges_to_rle_counts(ranges: Sequence[Tuple[int, int]]) -> List[int]
Convert sorted non-overlapping ranges to RLE counts. This is O(number of ranges) rather than O(number of points), making it efficient for large point sets represented as ranges. Arguments:
  • ranges - Sorted list of (start, end) tuples representing inclusive ranges. Ranges must be non-overlapping and sorted by start.
Returns: List of RLE counts alternating between empty and present runs