In this video we go over two solutions to the classic 0/1 knapsack problem, where a thief tries to maximize the value of items he can steal from a museum given that his knapsack can only hold a certain capacity.
The first (naive) solution is to try all possible ways of taking gems, but this is slow.
The dynamic programming (best) solution is to store the maximum value for each valid knapsack weight and item in a 2D array.
Link to webpage: https://www.srcmake.com/home/knapsack
Link to problem on hackerrank: https://www.hackerrank.com/contests/srin-aadc03/challenges/classic-01-knapsack
Twitter: https://twitter.com/srcmake
Twitch: https://www.twitch.tv/srcmake
Discord: https://discord.gg/q5vAET3
Download
0 formats
No download links available.
[Dynamic Programming] Classic 0/1 Knapsack Problem | NatokHD