Knapsack Variations

You know the core 0/1 knapsack. Now learn unbounded knapsack, bounded copies, and value-based state design.

46 lessons
209 min
Codeforces: 1400-2100LeetCode: 1600-2000

Lessons

1. Intro

What you'll learn

5m

2. Max Value to True/False

The shift

5m

3. LeetCode 416 Partition Equal Subset Sum - Problem Statement

LeetCode 416

5m1 problems

4. LeetCode 416 Partition Equal Subset Sum - The Hidden Knapsack

Finding the pattern

5m

5. LeetCode 416 Partition Equal Subset Sum - Boolean State Design

True or false

5m

6. LeetCode 416 Partition Equal Subset Sum - Implementation

The code

5m1 problems

7. LeetCode 416 Partition Equal Subset Sum - Walkthrough

Tracing subset sum

4m

8. Lessons from Partition

summary

5m

9. Challenge: Partition Reconstruction

Finding the actual subsets

4m

10. Quiz: Subset Sum Basics

Knowledge check

3m1 problems

11. LeetCode 494 Target Sum - Problem Statement

LeetCode 494

5m1 problems

12. LeetCode 494 Target Sum - Converting Signs to Subsets

The math

5m

13. LeetCode 494 Target Sum - Implementation

The code

5m1 problems

14. LeetCode 494 Target Sum - Walkthrough

Signs to subsets

4m

15. Quiz: Target Sum Transform

Testing the reduction

3m1 problems

16. Finding One to Counting All

The shift

5m

17. LeetCode 518 Coin Change II - Problem Statement

LeetCode 518

5m1 problems

18. LeetCode 518 Coin Change II - Combinations vs Permutations

The trap

5m

19. LeetCode 518 Coin Change II - Loop Order

The fix

5m

20. LeetCode 518 Coin Change II - Implementation

The code

5m1 problems

21. LeetCode 518 Coin Change II - Walkthrough

Counting combinations

4m

22. Lessons from Counting Knapsack

summary

5m

23. Challenge: Combinations vs Permutations

Understanding loop order

4m

24. Quiz: Counting in DP

Knowledge check

3m1 problems

25. Unlimited to Limited

The constraint

5m

26. Bounded Knapsack - Problem Statement

Classic variation

5m

27. Bounded Knapsack - Why Naive Is Slow

The problem

5m

28. Bounded Knapsack - Binary Representation

The trick

5m

29. Bounded Knapsack - Implementation

The code

5m

30. Bounded Knapsack - Walkthrough

Limited quantities

4m

31. Quiz: Binary Splitting

Why it works

3m1 problems

32. Quiz: Knapsack Types

Knowledge check

3m1 problems

33. One Constraint to Two

Multiple limits

5m

34. LeetCode 474 Ones and Zeroes - Problem Statement

LeetCode 474

5m1 problems

35. LeetCode 474 Ones and Zeroes - Two Capacities

3D state

5m

36. LeetCode 474 Ones and Zeroes - Implementation

The code

5m1 problems

37. LeetCode 474 Ones and Zeroes - Walkthrough

2D knapsack trace

4m

38. LeetCode 1049 Last Stone Weight II - Problem Statement

LeetCode 1049

5m1 problems

39. LeetCode 1049 Last Stone Weight II - Hidden Subset Sum

The observation

5m

40. LeetCode 1049 Last Stone Weight II - Implementation

The code

5m1 problems

41. LeetCode 1049 Last Stone Weight II - Walkthrough

Hidden subset sum

4m

42. Quiz: Last Stone Reduction

Understanding the transform

3m1 problems

43. Practice - Subset Sum Count

Apply counting pattern

5m

44. What's Next

Preview of 2D grid DP

4m

45. Pattern - Choosing the Right Variation

Decision guide

5m

46. Section Recap

What we learned

5m

Practice Problems

1.
Coin Change IILeetCodemedium

Classic unbounded knapsack counting combinations

2.
Perfect SquaresLeetCodemedium

Unbounded knapsack finding minimum count

3.
Cut RibbonCodeforcesmedium

Classic unbounded knapsack maximizing pieces

4.

Covered with full walkthrough in this section.

5.
Target SumLeetCode

Covered with full walkthrough in this section.

6.

Covered with full walkthrough in this section.

7.

Covered with full walkthrough in this section.

8.

Stack blocks with weight constraints - teaches sorting before DP and exchange argument.

Ready to start learning?

Access all 46 lessons with interactive content and progress tracking.