Overlapping interval pairs

Write codeEasy10 min

Your task

Given a list of closed integer intervals [start, end], count how many unordered pairs (i, j) with i < j overlap, that is, share at least one point. The list holds at most a few hundred intervals, so comparing every pair is acceptable. Example: [[1,3],[2,5],[6,8]] gives 1, because only the first two share points.

Examples

count_overlapping_pairs(intervals: list[list[int]]) -> int
Example 1
Inputcount_overlapping_pairs([[1, 3], [2, 5], [6, 8]])
Output1