Intervals
There are two types of intervals
Overlapping intervals
Non Overlapping intervals
They can be used to solve variety of problems:
Merge Overlapping Intervals: Given a list of intervals, merge overlapping intervals into a consolidated list of intervals. This can be used in scenarios like scheduling, time management, or resource allocation.
Non-overlapping Intervals: Given a list of intervals, find the maximum number of non-overlapping intervals that can be selected. This can be used in scenarios like task scheduling, activity selection, or maximizing resource utilization.
Interval Intersection: Given two lists of intervals, find the intersection between them. This can be used in scenarios like finding common availability slots, overlapping events, or time-based conflicts.
Interval Union: Given a list of intervals, find the union of all overlapping intervals. This can be used in scenarios like visualizing time ranges, determining the overall coverage of events, or determining the total duration of overlapping activities.
Interval Difference: Given two lists of intervals, find the difference between them (intervals present in one list but not in the other). This can be used in scenarios like finding available time slots, identifying gaps in schedules, or filtering out unwanted intervals.
Practice Problems
Merge Overlapping Intervals:
Problem: 56. Merge Intervals
Problem: 986. Interval List Intersections
Non-overlapping Intervals:
Problem: 435. Non-overlapping Intervals
Interval Intersection:
Problem: 986. Interval List Intersections
Problem: 986. Interval List Intersections
Interval Union:
Problem: 759. Employee Free Time
Problem: 1272. Remove Interval
Interval Difference:
Problem: 56. Merge Intervals
Problem: 986. Interval List Intersections
Last updated
Was this helpful?