Greedy Optimization
Classic optimization problems where greedy shines: fractional knapsack, job scheduling, and task scheduling. Learn when greedy gives optimal answers.
38 lessons
91 min
Codeforces: 1200-1800LeetCode: 1500-1800
Lessons
1. Intro
Optimization problems
2m
2. Problem - Fractional Knapsack
Take fractions
3m1 problems
3. Fractional Knapsack - Algorithm
Sort by ratio
3m
4. Fractional Knapsack - Implementation
The code
3m1 problems
5. 0/1 Knapsack - Why Greedy Fails
Discrete items block
3m
6. Quiz: Knapsack
Fractional vs 0/1
1m1 problems
7. Problem - Job Sequencing
Maximize profit with deadlines
3m1 problems
8. Job Sequencing - Algorithm
Latest available slot
4m
9. Job Sequencing - Implementation
The code
3m1 problems
10. Problem - Minimum Platforms
Railway station
3m1 problems
11. Minimum Platforms - Implementation
The code
3m1 problems
12. Problem - Task Scheduler
CPU with cooldown
3m1 problems
13. Task Scheduler - Algorithm
Count and formula
4m
14. Task Scheduler - Implementation
The code
3m1 problems
15. Quiz: Task Scheduler
Apply the formula
1m1 problems
16. Task Scheduler - Why This Works
The idle slots insight
2m
17. Problem - Reorganize String
No adjacent duplicates
2m1 problems
18. Reorganize String - Feasibility
When is it possible
2m
19. Reorganize String - Algorithm
Interleave by frequency
2m
20. Reorganize String - Implementation
The code
3m1 problems
21. Quiz: Reorganize String
Feasibility check
1m1 problems
22. Problem - IPO
Maximize capital
2m1 problems
23. IPO - Greedy Insight
enable then maximize
2m
24. IPO - Implementation
The code
3m1 problems
25. Problem - Minimum Cost to Hire K Workers
Wage ratios
2m1 problems
26. Hire Workers - The Idea
The ratio determines cost
3m
27. Hire Workers - Implementation
The code
3m1 problems
28. Quiz: Worker Hiring
Why ratio order
1m1 problems
29. Problem - Couples Holding Hands
Minimum swaps
2m1 problems
30. Couples - Greedy Approach
Fix each pair
2m
31. Couples - Implementation
The code
3m1 problems
32. The Greedy Optimization Pattern
Common structure
3m
33. Problem - Assign Cookies
Satisfy children
2m1 problems
34. Assign Cookies - Greedy Insight
Match smallest to smallest
2m
35. Assign Cookies - Implementation
The code
2m1 problems
36. Quiz: Greedy Matching
Why this order
1m1 problems
37. What is Next
Looking ahead
2m
38. Section Recap
What we learned
2m
Practice Problems
1.
Table Decorationscodeforces
2.
Modulo Sumcodeforces
3.
Number of Wayscodeforces
4.
Multisetcodeforces
5.
Examscodeforces
6.
Apple Treecodeforces
7.
Divide and Summarizecodeforces