4.5.1 0/1 Knapsack Problem (Program) - Dynamic Programming

Поделиться
HTML-код
  • Опубликовано: 3 мар 2018
  • 0/1 Knapsack Problem explained using Program
    PATREON : www.patreon.com/bePatron?u=20...
    Courses on Udemy
    ================
    Java Programming
    www.udemy.com/course/java-se-...
    Data Structures using C and C++
    www.udemy.com/course/datastru...
    C++ Programming
    www.udemy.com/course/cpp-deep...

Комментарии • 166

  • @willjay5114
    @willjay5114 6 лет назад +85

    You are an excellent teacher, sir. Your effort is much appreciated.

  • @flexerfadrigalan
    @flexerfadrigalan 3 года назад +8

    Awesome content, by far the most understandable and easy to understand. I aspire to be you when explaining a difficult topic.

  • @aaronaaronaaron5922
    @aaronaaronaaron5922 3 года назад +14

    I hope this AMAZING channel reachs millions of subscribers, THANKS, sirm you are awesome 🥊

  • @rahulchawla6696
    @rahulchawla6696 4 года назад +18

    Correction :
    cout

    • @arpitkumar4525
      @arpitkumar4525 3 года назад +4

      @Phantom mercy It exits the inner loop so w is out of scope.

  • @mauriciocmarinho
    @mauriciocmarinho 5 лет назад +10

    Best explanation about knapsack algorithm implementation on youtube. Thanks a lot!

  • @surajsuryawanshi7835
    @surajsuryawanshi7835 2 года назад +2

    No words to describe how excellent your teaching is .

  • @raghavddps2
    @raghavddps2 5 лет назад +8

    Sir, you are an excellent teacher. Thanks a lot...

  • @VanjeAv
    @VanjeAv Год назад +1

    I can't belive how talented you are

  • @phantomvisual
    @phantomvisual 7 месяцев назад +16

    future viewers, some things to note!!
    it's important for p[0] = wt[0] = 0 to exist. in the video, p and wt already have 0 at the start. this makes the table's first row and first column filled with 0.
    your implementation may need to change if your table's doesn't have that initial condition. you might see `p[i-1]` and `wt[i-1]` in other implementations, this is because the "p" and "wt" usually don't have 0 instantiated thus you shift everything over by 1 to fit the first row filled with 0 (therefore requiring you to do i-1 to index correctly).

  • @johnc4624
    @johnc4624 11 месяцев назад +5

    Taught very clearly!
    (Perhaps a little mistake at 15:26 ? Reducing i-- before accessing J for weight reduction would seems wrong ?)
    Thanks for this brilliant teaching sir

  • @051-avnee4
    @051-avnee4 2 года назад +1

    Sr, I have no words for appreciation of your way of teaching. I can't compare it with that of any other course faculties or youtubers. Its Unique ! I am following your course also for dsa from Udemy, i have successfully completed it and it happened first time with me that I am almost 90-95% satisfied with a purchased course and that is also at easily affordable cost. Thankyou So Much for your efforts for us, Sr. I want to pay Respect to you by heart !🙏

  • @lakshayaggarwal8661
    @lakshayaggarwal8661 6 лет назад +2

    Best video on data structure

  • @ajeetshankar7946
    @ajeetshankar7946 6 лет назад +3

    Really an awesome video sir , please discuss like this for other algos. too!

  • @sumant9120
    @sumant9120 3 года назад +59

    Breakdown of the formula:
    ⭐K: DP table which stores values of subproblems
    ⭐K[i, w]: Maximum profit by considering the first 'i' elements in a bag of weight 'w'
    ⭐p[i]+ K[i-1, w-wt[i]]: Case when the current object is included(~1) 'p[i]' and the remaining part of the bag 'w-wt[i]' must be filled with the maximum profit possible (stored at 'i-1')
    ⭐K[i-1, w]: Case when the current object is not included(~0) and the bag with current weight 'w' must be filled with the maximum profit possible (stored at 'i-1')
    (~ Hence the name 0/1 knapsack problem)

    • @henrycode679
      @henrycode679 9 месяцев назад

      Pls bro, I'll like you the explain more on that of k[i-1] work without leading to error, of course I know that it is related to o base index but for example if we have a loop like this
      String hold="" ;
      for(int i=0; i

    • @Harish-ry2qb
      @Harish-ry2qb Месяц назад

      omg thank you so much!

  • @ntaange-junior5536
    @ntaange-junior5536 3 месяца назад

    Thhank you teacher for this lesson and the previous one concrning the knapsack problem it is really well understood and well explained

  • @abhisheksagar3764
    @abhisheksagar3764 5 лет назад

    superb adn simple ,.happy to see your vieos ,

  • @allanonyango6447
    @allanonyango6447 3 года назад +4

    Thanks Sir! Your explanations never disappoint

  • @mrkyledescoudres1502
    @mrkyledescoudres1502 2 года назад +41

    I have now understood the meaning of the universe, the key to everything... but I cannot explain it (or give it) to you. You have to find it by yourself...

  • @SaraswatiShelke8788
    @SaraswatiShelke8788 27 дней назад

    you are just amazing sir as i have problem in english but i understood you explanation you are simply great sir
    thank you so much sir
    🙏🙏🙏🙏

  • @stutisflairs9622
    @stutisflairs9622 2 года назад +3

    This code is stuck in my mind from the way you explained thanks for taking so much efforts for us God bless uhh 🙏

  • @celsiusfahrenheit1176
    @celsiusfahrenheit1176 3 года назад +1

    I just purchased your C++ Programming!!!

  • @abhireshray8331
    @abhireshray8331 Год назад +2

    Best explanation,ever!!!

  • @AbdulMajid-eu9gl
    @AbdulMajid-eu9gl 5 лет назад +2

    Dear Sir Great work just these words i can say thanks alot

  • @parvinetibarli1283
    @parvinetibarli1283 3 года назад +2

    fantastic. Respect from Azerbaijan

  • @kayodeolakunleoluwaseyi4273
    @kayodeolakunleoluwaseyi4273 Год назад

    You are an amazing teacher

  • @devendradahale546
    @devendradahale546 3 года назад +1

    You 're really Great Sir

  • @bhargavsaigarlapati4380
    @bhargavsaigarlapati4380 7 месяцев назад

    good teacher is very small word for you sir!

  • @vakhariyajay2224
    @vakhariyajay2224 Год назад +1

    Thank you very much. You are a genius. 👍👍👌👌🔝🔝🙏🙏

  • @mohiuddinrahman6171
    @mohiuddinrahman6171 Год назад +1

    Ma sha Allah sir.... May Allah bless you!

  • @vibhavchirravuri4543
    @vibhavchirravuri4543 4 года назад +2

    sir please do videos on approximation and randomization algorithms

  • @shivamkumaryadav6249
    @shivamkumaryadav6249 6 месяцев назад +1

    last line " cout

  • @temurmannonov2473
    @temurmannonov2473 4 года назад

    thanks, you are good teacher

  • @4869shk
    @4869shk 6 лет назад +16

    Thank you sir, been following your videos for DAA and they're very helpful! I had a doubt, I'm not able to understand why 0/1 knapsack has exponential complexity, looking at the code it seems the program has O(n*m) complexity..

    • @Pankajkumar-dy9ef
      @Pankajkumar-dy9ef 6 лет назад +3

      you can think like generating the all the subsets of a set

    • @krishna1.097
      @krishna1.097 4 года назад

      Its also a possibility but complexity which we consider is worst case. So worst case complexity O(n*n)

    • @rasulosmanbeyli35
      @rasulosmanbeyli35 3 года назад +4

      Using dynamic programming, we may not call again functions for small values and take them immediately from a two-dimensional array and therefore the complexity is O (n * w), but if we called functions recursively, then the complexity would be O (2 ^ n)

  • @jaatharsh
    @jaatharsh 3 года назад +2

    Abdul Bari = GOD of DSA
    thanks a lot again for sharing gem of a video for us

  • @pattyharris
    @pattyharris 5 лет назад +7

    Excellent explanation. Thanks very much. One question - the "cout

    • @xarenwo
      @xarenwo 4 года назад +13

      You should put K[i][w] , and then a break line out of the loop , that way you get the table
      0 0 0 0 0 0 0 0 0
      0 0 1 1 1 1 1 1 1
      0 0 1 2 2 3 3 3 3
      0 0 1 2 5 5 6 7 7
      0 0 1 2 5 6 6 7 8
      Like this
      #include
      #define objects 4
      #define capacity 8
      using namespace std;
      int max(int a, int b) {
      if(a>b) {
      return a;
      }
      return b;
      }
      int main() {
      int Profit[objects+1] = {0,1,2,5,6};
      int Weight[objects+1] = {0,2,3,4,5};
      int Table[objects+1][capacity+1];
      cout

    • @henrycode679
      @henrycode679 9 месяцев назад

      ​​@@xarenwoPls bro, I'll like you the explain more on that of Table[i-1] work without leading to error, of course I know that it is related to o base index but for example if we have a loop like this
      String hold="" ;
      for(int i=0; i

  • @mohammedadel8948
    @mohammedadel8948 2 года назад

    Thank you for your efforts

  • @pritihinduja5262
    @pritihinduja5262 4 года назад

    best explanation thanks

  • @MukeshYadav-pt2uc
    @MukeshYadav-pt2uc 5 лет назад

    WOW........my god... too easy to understand here...

  • @codingexception6502
    @codingexception6502 3 года назад +1

    very nice explanation sir, Thank you ! :)

  • @sampreethrv675
    @sampreethrv675 5 лет назад +45

    there is small error in the code at 15:11 first we have to write j=j-wt[i] then i=i-1;

    • @KeyMajorSiddharth
      @KeyMajorSiddharth 3 года назад

      can you please explain why it is an error?

    • @sampreethrv675
      @sampreethrv675 3 года назад +2

      @@KeyMajorSiddharth we want the weight of ith object for j=j-wt[i] so if you decrement i first it will point to i-1 object

    • @shashanksagarjha2807
      @shashanksagarjha2807 3 года назад

      please watch this playlist for detailed explanation of dynamic programming..ruclips.net/p/PLeF0b8iqbx4mTBJZ5ukIYj92_B4k2L1-8..

    • @AhamedKabeer-wn1jb
      @AhamedKabeer-wn1jb 3 года назад

      remember that sir has made all the first elements of both the array as zero..so the previous element will point to zero..so he has used this logic..for that equation..

    • @lokranjanp3520
      @lokranjanp3520 10 месяцев назад

      @@AhamedKabeer-wn1jb no bro I think it still gives an error

  • @quansun861
    @quansun861 Месяц назад

    Sir, you have legendary white board brush hands

  • @dineshbabar5250
    @dineshbabar5250 6 лет назад

    Please give example for Advance data structure like:-kruskals algo,prims algo etc

  • @rajasaha1997
    @rajasaha1997 6 лет назад

    Thank You Sir.You are awesome

  • @Sourav9063
    @Sourav9063 3 года назад +3

    on 15:02
    It should be
    cout

  • @svdfxd
    @svdfxd 5 лет назад

    Awesome explanation sir....

  • @AhamedKabeer-wn1jb
    @AhamedKabeer-wn1jb 3 года назад +1

    THANK YOU SO SIR..WELL EXPLAINED ..

  • @user-np2xy8om8h
    @user-np2xy8om8h 5 месяцев назад

    thank you so much. I wish I would be your student. I am preparing for exam and I cant find knapsack problem with repetitions. I cant watch others videos, cause they arent so interesting.

  • @AnshuKumar-oj8ww
    @AnshuKumar-oj8ww 3 месяца назад +1

    Thanks a lot for the clear explanation, sir!
    1 thing I found out -
    While finding which object to be included at 15:30
    the statements should be in this order j = j - wt[i]; i--;
    and not reverse, which will give an incorrect result.

  • @arkpandey7679
    @arkpandey7679 5 лет назад

    thank you so much sir

  • @johnsmith-tc7nl
    @johnsmith-tc7nl 5 лет назад +8

    // return max profit and list of selected weights
    function knapsack({ profits, weights, capacity, n }) {
    // calculate and generate capacity / item table - the value of each unit will be maximum profit.
    // add one item at a time and calculate maximum profit per capacity
    // row: number of items -> n + 1
    // col: maximum capacity -> capacity + 1
    // NOTE: add one extra row and col and keep the all 0, this will help us with dynamic programming formula
    let ic = new Array(n + 1).fill(0).map(row => new Array(capacity + 1).fill(0));
    // ignore the first row and col
    // iterate over all items - rows
    for (let i = 1; i

  • @seerapuramesh7977
    @seerapuramesh7977 5 лет назад

    Excellent teaching

  • @SandVision03
    @SandVision03 4 года назад

    Godfather of DS & Algo.

    • @govindkothari7989
      @govindkothari7989 4 года назад +1

      He teaches how to mug up things in effective way. Even you don't know how the formula derived

  • @BECEG_Bodhit
    @BECEG_Bodhit 2 года назад +1

    Wherever I go... Always come here to find final answer

  • @yaswanthkosuru
    @yaswanthkosuru Год назад +2

    its wt[ i-1 ] not wt [i ] becausearray indexing at 0 onwards

  • @rj_artwork_studio
    @rj_artwork_studio Год назад +1

    Sir last m cout

  • @ghassanabokhaled1407
    @ghassanabokhaled1407 4 года назад

    Thank you man

  • @mdashifjamal6511
    @mdashifjamal6511 Год назад

    15:34 j should be updated before decrementing i ,or else it will substract weight of previous i

  • @kamalnathlp6814
    @kamalnathlp6814 5 лет назад

    @5.00 why we are comparing index value with weights

  • @Aryandwi007
    @Aryandwi007 Год назад

    Gurudev 🗿👑

  • @gunshipbattle5300
    @gunshipbattle5300 4 года назад

    thank you sir

  • @tanyasethi4674
    @tanyasethi4674 6 лет назад +2

    sir, please make a video on coin change problem, Dynamic Programming

  • @donnafernando8593
    @donnafernando8593 7 месяцев назад

    is it possible to combine greedy knapsack algorithm and dynamic programming in solving 0/1 knapsack problem? just to make it more efficient...

  • @nithin3476
    @nithin3476 Год назад

    My doubt is if the weight is included then we take Max function anyways the first parameter is always greater than second parameter so we always get max from the first parameter only why we take second parameter too....

  • @anandbaskaran
    @anandbaskaran 2 года назад

    I guess the order of both the solutions is O(n^2). The good news is that we came down from O(2^n) by discarding unnecessary combinations.,

  • @lovesharma4344
    @lovesharma4344 6 лет назад

    what happen if we have weight like 15,10,9,5 and m=8.....how can we make the table as our weight is so larger as compared to our items

  • @RohitMishra-ox6oy
    @RohitMishra-ox6oy 3 года назад +2

    In object included logic in else part i- - shoud be after j=j-wt[] condition so that i value changes after calculation of its weight i.e. of 8-5

  • @WillyCSchneider
    @WillyCSchneider Год назад

    Thanks for the great explanation. I have one doubt, if for a given object weight=0 and profit>0 does this program include it in the bag?

  • @AmitKumar-qh1ts
    @AmitKumar-qh1ts 5 лет назад

    Can we calculate something like ProfitDensity which will be profit divided by weight? Then sort items by profit density (dsc), weight (asc). Then pick up the items in order as long as there is space in the bag? Do you think this approach will give us the correct answer?

    • @AmitKumar-qh1ts
      @AmitKumar-qh1ts 5 лет назад

      @@abdul_bari Thank you sir, for responding. I had to do something very similar in a test program. I don't think I got it right in that test. But later I had this idea that I could have calculated Profit Density. Can you please tell if the answer with that approach will be correct or not? Even though it will be a different problem.

    • @undercover4874
      @undercover4874 Год назад

      @@AmitKumar-qh1ts No that will not guarantee the correct answer in all cases

  • @vikashprasad3279
    @vikashprasad3279 5 лет назад +1

    Sir i guess j=j-wt[i] will be before i--?

  • @Irshadgbl
    @Irshadgbl 2 года назад

    hi Sir I have taken your Udemy courses they were pretty worthy and more than what a normal Indian student expect, thank you so much, and I have created a course on computer graphics where I got $50 till now it has been just 50 days I have activated pioneer and Paypal but Im not getting a proper way how to deposit my earning to my bank account as it is not showing any such option, also I want to know what does Udemy organic purchase exactly mean if you will help me I will be grateful to you

    • @abdul_bari
      @abdul_bari  2 года назад +2

      You should link you Payoneer account in udemy payments.

  • @rajavandeeth1717
    @rajavandeeth1717 5 лет назад

    Sir I didn't understand from cout

    • @stephen10023
      @stephen10023 5 лет назад

      Without getting too technical, "cout

  • @rajghamsani2533
    @rajghamsani2533 4 года назад +3

    Is it necessary here that profit and weights have to be increasing order ?

    • @saminYasir007
      @saminYasir007 3 года назад +1

      no it is not. calculate by yourself for better understanding

  • @akhilgupta4997
    @akhilgupta4997 3 года назад +1

    Sir please make video on solving this problem by set method also🙏

  • @mohitpandey4655
    @mohitpandey4655 Год назад +1

    The order should be
    j-= wt[i]
    i--;

  • @infiniteunconditionallove1620
    @infiniteunconditionallove1620 5 лет назад

    thank you very helpful

  • @themetalmystic3988
    @themetalmystic3988 2 года назад

    Abdul Bari! You are an excellent teacher. I think there is a bug in your reconstruction logic. I think if you decrement i before assigning j to wt[i] you will get an invalid optimal solution. I think you want to say j-= wt[i--]. If I am wrong, let me know, as that effects my understanding of the algorithm. :-) Thank you for so many thorough explanations of so many important topics.

    • @mdfaizanansari9567
      @mdfaizanansari9567 Год назад

      Thanks brother. I was having this issue for a long time and couldn't figure out what was the problem. Now i understood why was the answer wrong.

  • @danyelizarov1327
    @danyelizarov1327 4 года назад +1

    I believe that’s a debugging process and not an explanation. As a summary, what’s the core idea behind all these manipulations? Who knows.. But code’s important! And here’s the code! Brilliant.

    • @Sirajkhan789
      @Sirajkhan789 3 года назад

      he explained the logic in previous video. which he says in the beginning of this video.

  • @gowthamreddy6383
    @gowthamreddy6383 3 года назад

    sir plz explain an algorithm for sets method

  • @Noah-357
    @Noah-357 Год назад

    I don't think using else was good because it will make the code vague. Also, at the last part, the while loop won't execute because it's ( I = 1 and j = 0) so the last object is not checked? So we need to use 'OR' right because it will be always true (true OR false) = true so the loop continues, and when both false the loop stops

    • @henrycode679
      @henrycode679 9 месяцев назад

      Pls bro, I'll like you the explain more on that of k[i-1] work without leading to error, of course I know that it is related to o base index but for example if we have a loop like this
      String hold="" ;
      for(int i=0; i

  • @jash2851
    @jash2851 2 месяца назад

    I faced an error with 2nd given else if condition and after debugging this line works fine for me.
    k[i][j] = maxFunction(p[i - 1] + k[i - 1][j - wt[i - 1]], k[i - 1][j]);

  • @rv0283
    @rv0283 6 лет назад +2

    in the previous video you have done"8-6=2" and search for 2 in previous row but now why are we not using that method?

  • @amornchotsingh3977
    @amornchotsingh3977 5 лет назад +4

    Thank you Sir, great explanation. Anyway, Can you give us trick to come up with mathematical equation above like k[i][w] = max(p[i]+l[i-1][w-w[i], k[i-1][w]) ? I seem to understand the problem, but in an isolated environment, I couldn't come up with a logical formula.

    • @subhajeetchakraborty1791
      @subhajeetchakraborty1791 3 года назад +1

      well i am beginner in programming and havent solved much of DP problems till now but can say , as of DP paradigm we see to achieve current step's optimisation , we compare and pick among prev step optimised solution and any prev solution part with current step addition, so here we apply max on these two ,1st prev step optimised version k[i-1][w] and current version is k[i-1][w-w[i]] + p[i] ,so here we are comparing with similar scenario thats why taking case from prev row and here k[i-1][w-w[i]] we are checking for rest of weight w-w[i] optimised part from prev solution with addition to the profit we are getting inn current state i.e. p[i]
      so thats what i think till now approach are being implemented

  • @Parajal12
    @Parajal12 4 года назад

    Hllo sir ,
    Can u tell me how k[2][4]=2;
    When i am calculating i am getting 3 in place of 2.Please check my problem .

    • @subhajeetchakraborty1791
      @subhajeetchakraborty1791 3 года назад

      I guess you would have rectified your problem but if not lemme help you out
      k[2][4] so item = i = 2, j = 4 column num i.e. instance or part of sack of total wt = 8,
      for item i = 2 weight is 3 (from above w[i] array ) basically weight for item 2 is 3 , as we check 3 less than j= 4 so we traverse case 2 ,
      k[i][j] = max( p[i] + k[i-1][j-w[i] ] , k[i-1][j] ) i am using j instead of w in the table , to avoid the confusion of the w in above array of w[i]
      so i-1 = 1 , j-w[2] = 4-3 = 1, p[i] = 2, j = 4
      so k[i-1][j-w[i] ] = k[1][1] = 0, p[i] = 2 hence p[i] + k[i-1][j-w[i] ] = 2 and k[i-1][j] = k[1][4] = 1
      so as you see out of these two parts (2 and 1 ) max is 2 so the result or value of k[2][4] = 2
      i am sure you would have been confused by the fact of using w in both places so use j in the loop pr table instead of w.

  • @bravodj1795
    @bravodj1795 4 года назад +1

    Should not that I be n-1 and has m-1
    Because n=5 and m=9
    But we want K[4][8]

  • @henrycode679
    @henrycode679 9 месяцев назад

    Hi, I so much enjoyed your tutor but I'll like you the explain more on how that of k[i-1] work without leading to error, of course I know that it is related to o base index but for example if we have a loop like this
    String hold="" ;
    for(int i=0; i

    • @phantomvisual
      @phantomvisual 7 месяцев назад

      the first "if" statement checks if either "i" or "w" equals to 0. there won't be a case where i-1 is negative because "i" won't be 0 due to the first check.

  • @harishch769
    @harishch769 6 лет назад +2

    bug in ur code while(i>0 && j>=0)

  • @manikantansrinivasan5261
    @manikantansrinivasan5261 3 года назад

    update j=j-wt[i] before i- - in else condition otherwise the output will be wrong

  • @priyankamalviya3613
    @priyankamalviya3613 5 лет назад

    Thanks a lot for the explanation sir! But I tried the code with wt: {2,3,7}; profit: {15,90,160}; & max weight allowed 20. I got 0 as result. Logically solving the problem, since 20 is allowed, we can take 6 of 3 weight (6 * 90) and 1 of 2 weight (which gives 15), so max profit allowed is 540 + 15 = 555. I tried the below code:
    #include
    int max(int a, int b) { return (a > b)? a : b; }
    int main()
    {
    // int p[] = {0,1,2,5,6};
    // int wt[] = {0,2,3,4,5};
    int p[] = {15,90,160};
    int wt[] = {2,3,7};
    int m = 20;
    int n = 4;
    int K[5][9];
    for (int i = 0; i

    • @mogomotsiseiphemo1681
      @mogomotsiseiphemo1681 5 лет назад +1

      The first values of vectors p and wt have to be zero. So, you have to use the following: p[] = {0, 15, 90, 160} and wt[] = {0, 2, 3, 7}
      Also
      int n = 3;
      int K[4][21];
      Moreover, you can only take zero or one of every object. Hence the name 0/1 knapsack problem.

  • @blazingspirit2153
    @blazingspirit2153 3 года назад

    his voice is similar to anil kumble

  • @hclsiva
    @hclsiva 3 года назад

    The explanation is Awesome. Need to know what if the weight is 100 ,223 ,345,4198 & profit is 100,200,350,1000. How to handle that? any condition is missing?

  • @neojai3514
    @neojai3514 3 года назад

    is it a top-down approach because of the filling the table or traversing the table from last element?

  • @niharikagupta6383
    @niharikagupta6383 2 года назад +1

    One Doubt in the tracing part
    in else part,
    i - - should be after j=j-wt[i]
    isn't it??

  • @rishabhvanwani
    @rishabhvanwani 4 года назад +8

    Best speed (optimal) - 1.75x

  • @baswarajsghali2074
    @baswarajsghali2074 4 года назад

    What if one element can be put twice inside a knapsack

  • @ashishsinha8893
    @ashishsinha8893 6 лет назад

    site is under construction sir???

  • @maneeshdwivedi1764
    @maneeshdwivedi1764 5 лет назад +1

    your c++ link is not working

  • @srivatsann7193
    @srivatsann7193 5 лет назад +2

    Sir,can you pls do a video for computing binomial coefficient?

  • @Pankajkumar-dy9ef
    @Pankajkumar-dy9ef 6 лет назад

    god!💐

  • @sarcaastech
    @sarcaastech 4 года назад

    Sir i-- should be after j=j-w[i];

  • @anubhavtyagi4359
    @anubhavtyagi4359 3 года назад

    there is a small error Those who are implementing it will know
    at 15:52 i>0 and j>=0

    • @bbblok2235
      @bbblok2235 Год назад

      yess sirrrr !! thanks for the correction