Question Bank

Greedy Algorithms Warm-Up

Difficulty: Easy

Identify when a greedy choice is correct and when it fails. Drills cover activity selection, coin change with canonical denominations, and Huffman intuition.

Question Bank
/

Greedy Algorithms Warm-Up

Greedy Algorithms Warm-Up

Identify when a greedy choice is correct and when it fails. Drills cover activity selection, coin change with canonical denominations, and Huffman intuition.

Question Bank
Easy
Python
4 questions
greedy
algorithms
quiz
fundamentals

728 views

13

Implement activity selection: given a list of (start, end) intervals, return the maximum number of non-overlapping intervals you can pick.

Examples

Example 1:

Input: intervals = [(1, 3), (2, 4), (3, 5), (0, 6), (5, 7), (8, 9)]
Output: 4
Explanation: Sort by end: [(1, 3), (2, 4), (3, 5), (5, 7), (0, 6), (8, 9)]. Accept (1, 3); skip (2, 4); accept (3, 5); accept (5, 7); skip (0, 6); accept (8, 9). 4 picks total.