Tags

Interval Problems

Interval Problems

1 lesson
8 problems
1 community item

interval-problems

Algorithms

1 lesson

Greedy (Intro)

Intermediate

55 min

2 prereqs

Given coin denominations of 1, 5, and 25, the greedy "take the largest coin that fits" strategy gives change optimally. Add a coin worth 10 to the system and greedy stays optimal. Replace 25 with 21 and greedy quietly breaks: making 63 cents now wants three 21s, but greedy says one 21 plus two 1s and ten more 1s. The same algorithm, the same input shape, and yet correctness depends entirely on a structural property of the problem. **Greedy (Intro)** explains exactly which property that is. You will learn to test for the greedy-choice property and optimal substructure, the twin ingredients that justify a greedy decision. The lesson covers the canonical problems where greedy provably works (activity selection by earliest end time, fractional knapsack by value-to-weight ratio, job scheduling with deadlines, the jump game, Huffman encoding) and walks through the exchange-argument style of correctness proof. It also shows where greedy fails (0/1 knapsack, coin change with arbitrary denominations) so you know when to reach for DP instead. In **Sorting (Elementary)**, you saw why sorting often costs `O(n log n)`; almost every greedy algorithm starts with a sort step. **Big-O Notation (Upper Bound)** gave you the language to express that cost. Next, **Dynamic Programming (Intro)** picks up where greedy fails, when the local optimum does not guarantee the global one.

Not Started

0%

Algorithms
Greedy
Sorting
Interval Problems
Problem Solving
Intermediate
Premium

Practice Problems

8 problems

Meeting Rooms

Free
Not Started
Easy

Given an array of meeting time intervals, determine if a person could attend all meetings without any overlap.

Interval Problems
Sorting
Beginner

747

5

Summary Ranges

Free
Not Started
Easy

Given a sorted unique integer array, return the smallest sorted list of ranges that cover all the numbers in the array.

Interval Problems
Beginner

248

7

Minimum Interval to Include Each Query

Not Started
Hard

Given a list of intervals and a list of queries, for each query find the size of the smallest interval that contains it, or -1 if no interval contains it.

Algorithms
Advanced
Sorting
Sweep Line
Heap
Interval Problems
Premium

1.1k

31

Insert Interval

Free
Not Started
Medium

Given a set of non-overlapping intervals sorted by start time and a new interval, insert the new interval and merge if necessary.

Interval Problems
Merge Intervals
Intermediate

913

7

Meeting Rooms II

Not Started
Medium

Given an array of meeting time intervals, determine the minimum number of conference rooms required to hold all meetings.

Algorithms
Intermediate
Greedy
Sorting
Sweep Line
Heap
Interval Problems
Meeting Rooms
Premium

1k

7

Merge Intervals

Free
Not Started
Medium

Given an array of intervals, merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input.

Interval Problems
Merge Intervals
Sorting
Intermediate

279

9

Minimum Arrows to Burst Balloons

Not Started
Medium

Given balloons represented as horizontal intervals, find the minimum number of vertical arrows needed to burst all balloons.

Algorithms
Intermediate
Greedy
Sorting
Interval Problems
Merge Intervals
Premium

238

3

Non-overlapping Intervals

Not Started
Medium

Given an array of intervals, return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.

Algorithms
Intermediate
Greedy
Sorting
Interval Problems
Merge Intervals
Premium

371

7