Tap here to switch tabs
Problem
Submissions

Problem: Number of Intersecting Interval Pairs II

Number of Intersecting Interval Pairs II counts pairs of inclusive intervals in an array that share at least one point, returning the total number of pairs with distinct indices.

Statement

You are given an array of intervals intervals, where intervals[i] = [start_i, end_i] represents an inclusive interval starting at $ ext{start}_i$ and ending at $ ext{end}_i$.

Two intervals intersect if they share at least 11 common point.

Return the total number of pairs (i,j)(i, j) with 0≤i<j<extintervals.length0 \le i < j < ext{intervals.length} such that intervals[i] and intervals[j] intersect.

Constraints:

  • 2≤n==2 \le n == intervals.length ≤105\le 10^5

  • intervals[i] = [start_i, end_i]

  • 0≤extstarti≤extendi≤1090 \le ext{start}_i \le ext{end}_i \le 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Intersecting Interval Pairs II

Number of Intersecting Interval Pairs II counts pairs of inclusive intervals in an array that share at least one point, returning the total number of pairs with distinct indices.

Statement

You are given an array of intervals intervals, where intervals[i] = [start_i, end_i] represents an inclusive interval starting at $ ext{start}_i$ and ending at $ ext{end}_i$.

Two intervals intersect if they share at least 11 common point.

Return the total number of pairs (i,j)(i, j) with 0≤i<j<extintervals.length0 \le i < j < ext{intervals.length} such that intervals[i] and intervals[j] intersect.

Constraints:

  • 2≤n==2 \le n == intervals.length ≤105\le 10^5

  • intervals[i] = [start_i, end_i]

  • 0≤extstarti≤extendi≤1090 \le ext{start}_i \le ext{end}_i \le 10^9