Practice Set Intersection Size At Least Two
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 2D integer array intervals where intervals[i] = [starti, endi] represents all the integers from starti to endi inclusively. A containing set is an array nums where each interval from intervals has at least two integers in nums. Return the minimum possible size of a containing set.
Source: Set Intersection Size At Least Two on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
intervals = [[1,3],[3,7],[8,9]]
Output
5
# Example 2
Input
intervals = [[1,3],[1,4],[2,5],[3,5]]
Output
3
# Example 3
Input
intervals = [[1,2],[2,3],[2,4],[4,5]]
Output
5
Constraints
1 <= intervals.length <= 3000
intervals[i].length == 2
0 <= starti < endi <= 10^8
Related LeetCode Problems
Practice more problems similar to Set Intersection Size At Least Two.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.