0-1 Knapsack problem - Inside code

Ғылым және технология

Source code: gist.github.com/syphh/955b71b...
Slides: 1drv.ms/p/s!AhunTZOxJvfsiiuV2...
🔴 Learn graph theory algorithms: inscod.com/graphalgo
⚙ Learn dynamic programming: inscod.com/dp_course
💡 Learn to solve popular coding interview problems: inscod.com/50problems_course
⌛ Learn time and space complexity analysis: inscod.com/complexity_course
🔁 Learn recursion: inscod.com/recursion_course
NB: This video is ad-free, you can choose to support Inside code by purchasing one of the courses above or dropping a super thanks!
NB2: Discounts of courses above are permanent
I also post content on LinkedIn (inscod.com/linkedin) and Instagram (inscod.com/instagram)

Пікірлер: 15

  • @sproga_265
    @sproga_2652 жыл бұрын

    It was interesting to see an actual mathematical solution to this. I've been solving stuff like this w/ Excel's Solver for years

  • @anishlushte4319
    @anishlushte4319 Жыл бұрын

    Need correction in code to check if weight is becoming negative before adding. let values= [ 60, 100, 120 ]; let weights = [ 10, 20, 30 ]; K = 50 code will return 280 instead of 220. Fix: if (weights[i] > k) return knapsack(values, weights, k, i+1)

  • @coding953

    @coding953

    3 ай бұрын

    Or Put `if(k

  • @leenavig3441
    @leenavig3441 Жыл бұрын

    very brilliantly explained. Lot of hard work to put this video together. Thank you for your effort!

  • @lordsixth5944
    @lordsixth59442 жыл бұрын

    Cant thank you more just wanted this problem to understand dp . Lot of love to you

  • @coding953
    @coding9533 ай бұрын

    There is a small mistake: `if(k

  • @abdulrehmanamer4252
    @abdulrehmanamer4252 Жыл бұрын

    Bro you really made my day.. I was stuck on it since the day 01..... Alhamdulillah!

  • @abdulrehmanamer4252

    @abdulrehmanamer4252

    Жыл бұрын

    And BTW nice animations!!

  • @subee128
    @subee128Ай бұрын

    Thanks

  • @omerfeyyazselcuk7325
    @omerfeyyazselcuk7325 Жыл бұрын

    thanks

  • @mytube5182
    @mytube51822 жыл бұрын

    doubt: how do i known which elements i have selected when i found max total value.

  • @Daniel_WR_Hart

    @Daniel_WR_Hart

    Жыл бұрын

    You can use a stack or a set to track the indices of the currently used elements, just make sure to remove the right indices from the collection when you backtrack

  • @jimbobago
    @jimbobago2 жыл бұрын

    FYI: dollar signs are written *before* the number - $20, not 20$.

  • @koushikreddy6718

    @koushikreddy6718

    Жыл бұрын

    so waht??

Келесі