DP-2 Dice Combinations | Problem Solving | Competitive Programming | DSA | CSES

Поділитися
Вставка
  • Опубліковано 18 вер 2024

КОМЕНТАРІ • 74

  • @TLE_Eliminators
    @TLE_Eliminators  10 місяців тому +2

    Watch this lecture if you find the concepts discussed in this video to be unknown: ua-cam.com/video/_OPJaU2Xz7o/v-deo.html. Basics of DP have been covered in this video.

  • @rahuljain4398
    @rahuljain4398 10 місяців тому +2

    Crystal Clear Explanation!! Understood very well

  • @neelkhandare5057
    @neelkhandare5057 10 місяців тому +1

    awesome lecture, loved it.

  • @hitensolanki8698
    @hitensolanki8698 3 місяці тому

    Very good explanation! Thank you.

  • @HarshKumar-rk4zm
    @HarshKumar-rk4zm 10 місяців тому +1

    Thanks Priyansh Bhaiya, I was able to solve this problem by own after watching first lecture but was unable to implement approach 2.🙂

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +6

      Approach 2 is just the reverse of approach 1.
      Approach 1:
      state: dp[i] = number of ways to reach a sum of i
      transition: dp[i] = sum(dp[i-1], dp[i-2]... dp[i-6])
      base case: dp[0] = 1, as number of ways to generate 0 is just 1
      final subproblem: dp[n] as we finally want to find the number of ways to get n
      Approach 2:
      state: dp[i] = number of ways to go from i to n
      transition: dp[i] = sum(dp[i+1], dp[i+2]... dp[i+6])
      base case: dp[n] = 1, as number of ways to go from n to n is just 1
      final subproblem: dp[0] as we finally want to find the number of ways to go from 0 to n
      What's the issue you faced in implementing?

    • @HarshKumar-rk4zm
      @HarshKumar-rk4zm 10 місяців тому +3

      @@TLE_Eliminators Because I was doing recursively and memoising . I was able to understand the first but second one took some time to understand.

  • @Braveuser-x7j
    @Braveuser-x7j 10 місяців тому +1

    Nice sir, would it be possible to create a playlist for another topic? It would be really helpful.

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +4

      Let's finish this one off first and then we can plan more content.
      We also have our upcoming TLE 9.0 course coming up in December 1st week that you can explore in case you're interested in other topics than DP

  • @sair751
    @sair751 10 місяців тому

    understood, very clear explanation :)

  • @ishan_bhusari
    @ishan_bhusari Місяць тому

    OG video!

  • @JIGARSINGTHAKOR-yy6qp
    @JIGARSINGTHAKOR-yy6qp 10 місяців тому

    Just wow❤

  • @hritik4807
    @hritik4807 10 місяців тому +1

    Can you please discuss the bonus problem i am not getting it perfect solution anywhere it will be a great help Priyansh

  • @rajajairamrameshbabu7605
    @rajajairamrameshbabu7605 8 місяців тому

    Nice explanation

  • @mrinalanand2317
    @mrinalanand2317 10 місяців тому

    great priyansh bhaiya

  • @physicsakhada592
    @physicsakhada592 10 місяців тому +1

    Try to start with a recursive solution then memo. And then tabulation ..
    If you can give hint like how to do it recursively I have tried but confused.

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      We would suggest watching this video and you'll understand completely how to implement: ua-cam.com/video/_OPJaU2Xz7o/v-deo.html.

  • @studentforlife5502
    @studentforlife5502 8 місяців тому

    Recursive approach tried:
    long long int num_of_ways(long long int n){
    if(n

  • @anonymousanonymous7507
    @anonymousanonymous7507 8 місяців тому +1

    for (int i = n ; i >= 0; i--) {
    for (int j = 1; j

  • @luckysharma3423
    @luckysharma3423 10 місяців тому

    Awesome bro..

  • @vikasseervi1500
    @vikasseervi1500 10 місяців тому +1

    I would love to see the explanation with an example.

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +2

      As it not possible to fit an example in the video now, here's one example that can help you understand better.
      Let's suppose we are solving for n = 8
      dp[i] being number of ways to generate a sum of i
      dp[0] = 1 (base case)
      dp[1] = dp[0] = 1
      dp[2] = dp[1] + dp[0] = 2
      dp[3] = dp[2] + dp[1] + dp[0] = 4
      dp[4] = dp[3] + dp[2] + dp[1] = 8
      dp[5] = dp[4] + dp[3] + dp[2] + dp[1] + dp[0] = 16
      dp[6] = dp[5] + dp[4] + dp[3] + dp[2] + dp[1] + dp[0] = 32
      dp[7] = dp[6] + dp[5] + dp[4] + dp[3] + dp[2] + dp[1] = 63
      dp[8] = dp[7] + dp[6] + dp[5] + dp[4] + dp[3] + dp[2] = 125
      Hope this helps.

    • @vikasseervi1500
      @vikasseervi1500 10 місяців тому

      @@TLE_Eliminators Yes it helped me and I hope you add a example with explanation in upcoming videos.

  • @DIVYANSCKASHYAP
    @DIVYANSCKASHYAP 10 місяців тому +1

    why are we adding dp[k-i], 6 times to get dp[k] ??

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      The value of 'i' is different in all those 6 ways. You can get to k from k - 1, k - 2, k - 3, k - 4, k - 5, k - 6. So you add k - i, 6 times, each time with a different value of i.

  • @harshbgmi7261
    @harshbgmi7261 10 місяців тому +1

    Sir, could you please also share the slides for future reference. It will help us a lot if you provide a link for the same in description.

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      We are not going with slides. Priyansh writes all the stuff live while teaching.

    • @dame574
      @dame574 10 місяців тому

      @@TLE_Eliminators please share the live slide itself for future reference , if possible

  • @mohdalizilani9896
    @mohdalizilani9896 10 місяців тому

    Bro make small playlist of Digit dp as well , i could not found quality content for this topic on yt

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      We can consider that after this playlist. Btw, we will be teaching that in TLE Eliminators Level 4 which will be starting in December first week. You can check that out too if you're interested.

  • @sukhendupatra2192
    @sukhendupatra2192 9 місяців тому

    awesome

  • @mojammelhaque7823
    @mojammelhaque7823 8 місяців тому +1

    Is anyone solve the bonus problem (frog jump ii)?
    I didn’t find any dp solution.
    .
    If anyone can, please help.

  • @RohitGupta-oy2qt
    @RohitGupta-oy2qt 4 місяці тому

    Getting tle in python although approach is same.
    Please explain

  • @harshith1424
    @harshith1424 10 місяців тому

    Great explanation ❤ please dont stop this series ❤❤❤i just had a doubt . I know basics of recursion...like i dont know advance topics like backtracking, subsequences etc...but i can understand basic recursion being used in the series ....can i still continue the series or should i learn them first

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      There is no pre-requisite for this playlist as such. You can learn the concepts along the way as well. Just try to grasp as much as you can. If you're stuck somewhere you can make a comment and we can provide you with the right guidance or resource to go forward.

    • @harshith1424
      @harshith1424 10 місяців тому

      @@TLE_Eliminators thank you

  • @abhaypatel54321
    @abhaypatel54321 10 місяців тому

    thanks sir

  • @ShamimRasel-g5r
    @ShamimRasel-g5r 10 місяців тому

    Understood

  • @Manishkumar-mw2zw
    @Manishkumar-mw2zw 10 місяців тому

    Nice

  • @VivekSharma-eh2tv
    @VivekSharma-eh2tv 3 місяці тому

    what is the one way to achieve sum of 0 ???

    • @VimanshMahajan
      @VimanshMahajan 2 місяці тому

      do not throw the dice.. that is the way

  • @DIVYANSCKASHYAP
    @DIVYANSCKASHYAP 10 місяців тому

    please can you explain Approach 1 ?

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      We would suggest watching the playlist in the series in order to understand everything. You can start from the first video to get started.

  • @saikiranreddymekala1346
    @saikiranreddymekala1346 10 місяців тому +1

    Recursive + memo in python giving TLE

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +1

      Try iterative code. As explained by Priyansh, recursive codes are slower than iterative codes. Also, on CSES the time limit is very tight so generally recursive codes get a TLE.

    • @kartiknagrale1479
      @kartiknagrale1479 8 місяців тому

      store calculated values and then use them to calculate bigger value

  • @syedhamzashah3803
    @syedhamzashah3803 10 місяців тому

    Shouldn't the base case be Dp[0] = 0 bcoz we don't need to roll any dice.

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +1

      Dp[i] = number of ways to get a sum of i
      Dp[0] = 0, because number of ways to get a sum of 0 is 1 way, that 1 way is in which you don't roll any dice.
      This is similar to how we write 0! = 1 because number of ways to arrange 0 items is 1, that 1 is way is to not do anything.

  • @hardeepkumar6057
    @hardeepkumar6057 10 місяців тому

    Can you please provide link to solve this question. Leet code or any other link

  • @Technology_Forum
    @Technology_Forum 10 місяців тому

    which theme are you using in sublime text

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      Brogrammer

    • @Technology_Forum
      @Technology_Forum 10 місяців тому

      @@TLE_Eliminators - which app is used for recording on the ipad and on mac laptop

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      @@Technology_Forum Goodnotes

  • @sachinkadyan1435
    @sachinkadyan1435 10 місяців тому

  • @abhishekc3556
    @abhishekc3556 10 місяців тому

    explanation was good but no offence, it would've been better if you had wrote the recursive soln first and then gone to the iterative one. Kind of hard to come up with a recursive soln by myself considering I've never studied dp before and this is a beginner playlist.

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому

      We believe you're watching this video with a bias that one must come up with a recursive solution first for every dp problem and then go to the iterative solution. The main aim of this playlist is to help you give up on that bias. The single most generic way to think about a DP problem is in terms of subproblems. Now for the code, if a state is dependent on some other states, you need to make sure that the states on which we depend are calculated first because only then we can calculate our current answer.

  • @deepak1668
    @deepak1668 10 місяців тому +2

    I liked , it feels like paid series but age jake quality mat gira dena please

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +1

      don't worry, Priyansh never drops his quality irrespective of whether it is a paid course or a free playlist on UA-cam.

    • @mojammelhaque7823
      @mojammelhaque7823 8 місяців тому

      ​Is the given bonus problem either frog jump ii or frog jump? ​@@TLE_Eliminators

  • @musaddikkhan9720
    @musaddikkhan9720 10 місяців тому

    Hiey priyansh Bro it is Day02 here i go with my feedback can you also share you ipad / canvas notes i don't what it is.... and i can't recognized for 2nd code why we writing j

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +1

      1. Sure, we will get the notes added in the description.
      2. In the 2nd approach, dp[i] = number of ways to go from i to n. So, you are going higher from i by adding j to it. Now, you want to go from i to n and you're adding j for that. Clearly, if i + j > n, then you will never reach n, you will cross it. so that is i + j

    • @musaddikkhan9720
      @musaddikkhan9720 10 місяців тому

      @@TLE_Eliminators Okay Thanks now i get it the 2nd point .. I'll be Okay to watch again no issue for that it is normal feedback and if you also add some test case with dry run like you mantion in some one comments for n = 8 . but you don't explain it in video just add it in comments or description we will do by ourself it'll be helpful Thanks Again for checking comments ☺️

  • @abc-ym4zs
    @abc-ym4zs 10 місяців тому

    sir can u tell me what are the topics we need to concentrate more in dsa in order to improve in DSA problem solving

    • @PriyanshAgarwal
      @PriyanshAgarwal 10 місяців тому

      Linked List, BST, Stacks, Queues, DP, Graphs, Trees, String Algos and Tries

    • @abc-ym4zs
      @abc-ym4zs 10 місяців тому

      @@PriyanshAgarwal sir in string algos in which questions we need to concentrate more sir

  • @manindhra748
    @manindhra748 10 місяців тому

    #day2

  • @psnt_rwt
    @psnt_rwt 3 місяці тому

    not understood

  • @krishneshchaurasia3839
    @krishneshchaurasia3839 10 місяців тому

    I know that the solution is accepted but shouldn't ways to get 0 be 0

    • @TLE_Eliminators
      @TLE_Eliminators  10 місяців тому +1

      Going from 0 to 0, there is 1 way. That way is where you don't pick up any coin.
      It is similar to saying 0! = 1, number of ways to arrange 0 elements is 1.

  • @ballapranavachaitanya3975
    @ballapranavachaitanya3975 3 місяці тому

    hi bro i think this is also working
    vll dp(1000001,-1);
    void solve()
    {
    ll n;cin>>n;
    cout