Stone Game II | Game Strategy | EASIEST Explanation | META | Leetcode-1140 | Live Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 103

  • @Codewithminutecoder
    @Codewithminutecoder ปีที่แล้ว +32

    "I finally found the best explanation on TH-cam after watching several videos, as none of the others were able to provide me with such clear and thorough understanding as this one did."
    Thanks for this😊😊

  • @sumit_verma77
    @sumit_verma77 10 หลายเดือนก่อน +13

    After wasting 3 hour's finally I made them worth by watching this video. Thanks

  • @AbhijeetMuneshwar
    @AbhijeetMuneshwar 2 หลายเดือนก่อน +3

    Respected MIK Sir,
    I wish TH-cam would have allowed me to like this video multiple times.
    Such a clear and simple explanation.
    Thank you so much, Sir. 🙏🙇

  • @unknown47896
    @unknown47896 4 หลายเดือนก่อน +11

    bro i wonder how did u gain this much of knowledge and be able to teach in this way...i really salute to ur efforts and dedication

  • @leetcoder6569
    @leetcoder6569 ปีที่แล้ว +23

    Although I've studied my entire dp from striver, but the only person in youtube who explains equally good to him is u..
    But one suggestion, plz try taking at least 1 test case for sample run.. ❤❤❤

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +7

      Thank you so much.
      Your comment made my day.
      And definitely i will work on the suggestion you have given.
      Thank you once again for your precious feedback ❤️❤️❤️

    • @vaibhav454
      @vaibhav454 9 วันที่ผ่านมา

      Striver sidha bottom up k ratte marwata hai, mik bhai bottom up krate hi nhi

    • @codestorywithMIK
      @codestorywithMIK  9 วันที่ผ่านมา +1

      @vaibhav454 hello there,
      Kindly try my “DP Concepts & Qns” playlist where I teach recur+memo as well as bottom up 😇🙏♥️
      th-cam.com/play/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt.html&si=eGXOTIfFJx2fQ9W-
      More coming soon in that playlist ♥️

    • @vaibhav454
      @vaibhav454 9 วันที่ผ่านมา

      @@codestorywithMIK No doubt, u explains better than striver, babbar but try to discuss bottom up as well as space optimized approaches for all dp ques...

  • @gui-codes
    @gui-codes 2 หลายเดือนก่อน +7

    one of the finest explanations for this problem.

  • @procontent23
    @procontent23 ปีที่แล้ว +9

    You are so good🎉❤
    Ur work is Admirable🤗

  • @AishwaryaAishwarya-e4l
    @AishwaryaAishwarya-e4l ปีที่แล้ว +2

    hi i thankyou ...firstly ur explanation is excellent..secondly i am able to solve questions without referring to youtube like if any person solved or not..thirdly ur explanation touch core logic ...thankyou sooooo much😄😄😄

  • @udaykumarchetla6205
    @udaykumarchetla6205 ปีที่แล้ว +6

    Bro good explanation but one request from my side is to dry run for atleast one example case. So it clears lot of things like how the recursion is working. And also recursion tree. Earlier I told you abt this. no problem if the video goes for long. Thanks

  • @vineetkumar2899
    @vineetkumar2899 ปีที่แล้ว +2

    Waoo!🤗 learn new technique.

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +1

      Thanks a lot for watching Vineet ❤️❤️

  • @alokgautam02
    @alokgautam02 ปีที่แล้ว +1

    Best solution available on youtube .🤩

  • @PIYUSHMAKAD
    @PIYUSHMAKAD 2 หลายเดือนก่อน +1

    Great knowledge

  • @aws_handles
    @aws_handles 2 หลายเดือนก่อน

    Legend ho aap 🫡

  • @Divyansh-x7n
    @Divyansh-x7n 9 หลายเดือนก่อน

    best explanation and solution for this question is found in this video

  • @MeherGeethaReddy
    @MeherGeethaReddy 2 หลายเดือนก่อน +2

    Very good explaination..thank you!

  • @xortixgaming655
    @xortixgaming655 ปีที่แล้ว +2

    Loved your explanation ♥

  • @AlishaKhan-ww3io
    @AlishaKhan-ww3io ปีที่แล้ว

    One of the finest explanations.

  • @chaitanya812
    @chaitanya812 ปีที่แล้ว +2

    bhai maja aagya nya concept smj ke

  • @souravjoshi2293
    @souravjoshi2293 ปีที่แล้ว

    LEGEND is here 🔥

  • @ugcwithaddi
    @ugcwithaddi ปีที่แล้ว +2

    Best explanation

  • @manishkumarprajapati6280
    @manishkumarprajapati6280 2 หลายเดือนก่อน +2

    Bhai... "Game Strategy" ki bhi ek playlist bana do na plz

  • @raunakkumar6144
    @raunakkumar6144 ปีที่แล้ว +1

    Bro can you make video on stone game 1 too.
    The explanation of that question is conflicting with this one (i watched someone else video),
    like his explanation was when you have choise chose best , but expect the worse
    which made sense to me as other player is playing optimally .

  • @UmmeKNeha
    @UmmeKNeha 2 หลายเดือนก่อน +1

    The explanation is really soo good. But I've a request when you explain pls cover the left over topics too. just in this q you explain all the things in a minority details which is really appreciable but when you use dp for memorization you just write the code which is fine but person like me who don't really understand dp well this seems a bit confusing.
    p.s: tho I watch 38 min but u caught my attention such a way that after finishing it seems to me like 5 min

  • @vishal-sr5et
    @vishal-sr5et ปีที่แล้ว +2

    Bro keep on posting videos , u will rise soon ✨

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว

      Sure thing.
      Thank you 🙏😇

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว

      Today’s upload will be a little delayed because I am travelling. But I have provided the link of my GitHub code (exact copy of LCS code pattern) in my post in TH-cam
      Thank you 🙏😇

    • @unknown47896
      @unknown47896 4 หลายเดือนก่อน +1

      @@codestorywithMIK yes bro...one day you will reach one million soon...btw hatsoff to your dedication bro...

  • @allansmith9964
    @allansmith9964 2 หลายเดือนก่อน +1

    13:27 and I just changed 1 Line of my code ---> accepted !!!

  • @harshjain8139
    @harshjain8139 ปีที่แล้ว

    Bro can you explain recursion tree for the above problem

  • @floatingpoint7629
    @floatingpoint7629 2 หลายเดือนก่อน

    @MIK playlist kab aye gi?

  • @horccruxxxop4184
    @horccruxxxop4184 ปีที่แล้ว +1

    Bhai minimum wala concept pls btado ..and aese he tutorials dia kro ap

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว

      Sure thing.
      It will come in my DP concepts playlist where I will teach Game Strategy
      Thanks a lot for watching ❤️❤️

  • @mohammedansil2302
    @mohammedansil2302 2 หลายเดือนก่อน +1

    and now we can say we have our own Neet code

  • @aizad786iqbal
    @aizad786iqbal 2 หลายเดือนก่อน

    so stones can be picked from the first piles only, it can not be like that, Alince can pick the pile having max stone..
    I see there are 9 questions int the series, u have covered 3rd also,
    I will try those once I start from scratch again,
    rn I just focus on daily potd and solutions...

  • @honey6567
    @honey6567 ปีที่แล้ว +1

    you are legend sir

  • @vetlakvsatyanarayana746
    @vetlakvsatyanarayana746 ปีที่แล้ว +1

    Please also explain MinMax Algorithm ❤

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว

      Sure thing. Planning to add this topic in my DP concepts playlist

  • @mohammadsaquibabbas1152
    @mohammadsaquibabbas1152 ปีที่แล้ว +2

    Hlo MIK Sir really enjoyed this video even my sir leave this question due to tricky statement BUT I request you also to derive problem by Recursion Tree Of any recursive problem that would be easy and for Interview. #RecursionTree

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +1

      Sure thing Saquib. Noted
      Will take care of this for sure ❤️

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 2 หลายเดือนก่อน

    NICE SUPER EXCELLENT MOTIVATED

  • @recessionriche
    @recessionriche ปีที่แล้ว +1

    Why do we not need to add stones for Bob?
    Also why Math.max(M,x)
    Isn't x the place where we are currently in piles?

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว

      If you notice, We are never considering the stones taken by Bob to find result.
      The stones is stored in stones variable and it contributes to result only in if(Person == Alice)
      Now, in the question its mentioned that M gets updated after every pick (say x) by value max (M, x)

    • @recessionriche
      @recessionriche ปีที่แล้ว

      But if the stones by Bob are not getting considered, what are we updating the result variable with?

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +1

      Then, we fetch result from next solve call for Alice
      result = min(result, solve(Alice))

    • @recessionriche
      @recessionriche ปีที่แล้ว +1

      @@codestorywithMIK ohhhh got it thank you very much!

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +1

      Thank you so much. I am glad it helped

  • @aswithasai4015
    @aswithasai4015 ปีที่แล้ว +2

    saviour thank you

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +1

      Thank you so much for watching 🙏❤️😇

  • @kushaalrana
    @kushaalrana 3 วันที่ผ่านมา

    bhaiya GameStratergy ka playlist nahi mil raha hai can you share if possible(Checked your channel too)

    • @codestorywithMIK
      @codestorywithMIK  3 วันที่ผ่านมา

      I have not yet created playlist for game strategy. Will soon plan that ❤️🙏

  • @JJ-tp2dd
    @JJ-tp2dd ปีที่แล้ว +2

    Bhai I know you are already working on DP playlist but if possible please try to complete the graph concepts series as well soon. I think just 5-6 topics are left then it will be completed. Sorry for putting you through this ❤💙♥

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +2

      No worries Abhijeet.
      I am planning to upload videos on both this weekend. Dont worry both will come
      ❤️❤️❤️

    • @JJ-tp2dd
      @JJ-tp2dd ปีที่แล้ว +1

      @@codestorywithMIK Thank you so much bhai 😍❤❤

  • @yereneager
    @yereneager 2 หลายเดือนก่อน

    bhaiya ek dry run hojata example se to better smjhta, min wala case bahot confuse kr rha

  • @thekindspill
    @thekindspill ปีที่แล้ว

    Legend ❤

  • @floatingpoint7629
    @floatingpoint7629 ปีที่แล้ว +1

    thanks for this !!!

  • @keertilata20
    @keertilata20 ปีที่แล้ว +1

    🔥🔥best

  • @BlueRadio_Official
    @BlueRadio_Official ปีที่แล้ว

    And the space is O(N) Right as maximum stack depth can go to N ONLY.

  • @snehagoyal4978
    @snehagoyal4978 ปีที่แล้ว +1

    amazing

  • @keertilata20
    @keertilata20 ปีที่แล้ว +1

    bhaiya stone games ke sare version par similar videos bna do please

  • @aizad786iqbal
    @aizad786iqbal 2 หลายเดือนก่อน +1

    answer to rat gaya mughe, but abhi bhi ek doubt hai
    if we are picking the min for bob, then how is that an optimal play, wouldn't bob want to pick max as well ..
    and bob mai kyun stone add nahi hua wo bhi nahi clear hua
    please clear this doubt,

    • @tomiokascuteness1909
      @tomiokascuteness1909 2 หลายเดือนก่อน +1

      I think min for bob means minimum bob is expecting alice to take. As we're solving for alice, so for Bob alice should have minimum hence.

    • @brokegod5871
      @brokegod5871 หลายเดือนก่อน

      The idea goes both ways. We are trying to focus on Alice by exploring all ways, the similar could have been done by Bob too if we focused on him. It's about whose POV you are focusing to solve
      We are trying to find how many Alice can take, why should we add what Bob took

  • @mudassarnazar1663
    @mudassarnazar1663 ปีที่แล้ว +1

    Thanks bhai ❤❤

  • @thedarkknight1865
    @thedarkknight1865 ปีที่แล้ว +1

    best explaination

  • @BlueRadio_Official
    @BlueRadio_Official ปีที่แล้ว

    The time complexity of this code is : O(N*N) because we the for loop can iterate M times and in the worst case it can be equal or close to N. And for each turn the overall calls can make is N hence O(N*N) Right mik bro?

    • @BlueRadio_Official
      @BlueRadio_Official ปีที่แล้ว

      This T. C & S. C is after excluding the memoization

  • @chetnamittal9537
    @chetnamittal9537 3 หลายเดือนก่อน

    did not understand why you wrote minimum (was expecting an explaination on this imp part)

    • @tomiokascuteness1909
      @tomiokascuteness1909 2 หลายเดือนก่อน

      I think it's because as we are solving for alice so bob expects alice to get minimum hence.

  • @AryanTomar_2025
    @AryanTomar_2025 ปีที่แล้ว +2

    Bhaiya did not get the logic behind why we do min in case of bob ............

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +1

      Hi Aryan,
      Actually this is Optimal Game Strategy.
      Since the function is written to return Alices score, so when it’s turn of Bob, Alice will expect worst from Bob and hence minimum from Bob is chosen.
      This is actually a Optimal Game Strategy qn and I will be teaching more on this topic and will be solving more qns on this in my DP Concepts and Qns playlist for sure.

    • @AryanTomar_2025
      @AryanTomar_2025 ปีที่แล้ว +1

      @@codestorywithMIK oh thanks bhaiya , now i understand after some time 😅 and one more request bhaiya , in next questions can yo do dry run of code with one of the example of recursion like how recursion work in these type of questions this will clear all doughts of questions it only take 5-10 min but it is very useful for us

    • @codestorywithMIK
      @codestorywithMIK  ปีที่แล้ว +2

      Sure thing Aryan. Noted ❤️❤️❤️

  • @palkeshpatnayak5994
    @palkeshpatnayak5994 ปีที่แล้ว +1

    In second case why Alice is not getting answer of 110

    • @AnkitSingh-tm5dp
      @AnkitSingh-tm5dp ปีที่แล้ว +1

      Because both play optimal bob also try to maximize our answer

  • @JJ-tp2dd
    @JJ-tp2dd ปีที่แล้ว +2

    Thank you bhai ❤💙 Java:
    class Solution {
    private int n;
    private int[][][] t;

    private int solve(int[] piles, int person, int i, int M) {

    if(i>=n) return 0;

    if(t[person][i][M] != -1)
    return t[person][i][M];

    int result = person==1 ? -1 : Integer.MAX_VALUE;
    int stones = 0;

    for(int x=1; x

  • @codeandtalk6
    @codeandtalk6 ปีที่แล้ว

  • @dipalibohara5679
    @dipalibohara5679 2 หลายเดือนก่อน

    Could you please send me your dp playlist link

    • @codestorywithMIK
      @codestorywithMIK  2 หลายเดือนก่อน +4

      I usually create two playlists for every topic :
      1) Concepts Playlist - Contains from basic concepts to expert concepts.
      2) Popular Interview Problems playlist.
      I have created concepts and interview problems playlist for
      1) Graph
      2) Recursion
      3) DP
      4) Segment Tree
      Planning soon to create concepts playlist for Tree as well.
      Graph Concepts - th-cam.com/play/PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY.html&si=lZG2IJTmSW4kRrx-
      Graph Popular Interview Problems - th-cam.com/play/PLpIkg8OmuX-I_49pdy1XFY6OcATnxUrrO.html&si=CG2JvGWVmvoSqvWA
      Recursion Concepts - th-cam.com/play/PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM.html&si=614iI4NyHY-FTeJH
      Recursion Problems (In progress) - th-cam.com/play/PLpIkg8OmuX-IXOgDP_YYiJFqfCFKFBDkO.html&si=88fBhRnr62OYTnDP
      DP Concepts (In progress) - th-cam.com/play/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt.html&si=laFVYy6ep2BkOg0s
      DP Popular interview problems - th-cam.com/play/PLpIkg8OmuX-L_QqcKB5abYynQbonaNcq3.html&si=VHEn9b-wqTnAVyyi
      Segment Tree Concepts -
      th-cam.com/play/PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB.html&si=xm7DqRN4H0eZwna4

    • @dipalibohara5679
      @dipalibohara5679 2 หลายเดือนก่อน

      @@codestorywithMIK thank you 🙂

  • @mannchadarana5322
    @mannchadarana5322 ปีที่แล้ว

    Can you tell me what is problem in this code
    int solve(int index, vector &piles, int n, int M, int person)
    {
    cout

  • @aryanraj9235
    @aryanraj9235 ปีที่แล้ว +2