I was legit waiting for your video on this, thanks, as usual awesome explanation
@spinacker163 ай бұрын
Medium problem? why not easy?
@sahebraojadhav97273 ай бұрын
Bro I understand the solution of dp but fails to create my own solution what should I do to better in dp please reply
@Alpha-Code3 ай бұрын
You should do easier dp problems until you can create your own solutions then once you can do easier ones yourself consistently try slowly increasing difficulty. Start with some really basic ones where you have some basic choices to make like go down or right or something. Then go to mediums then go to hards.
@sahebraojadhav97273 ай бұрын
I have doubt in our example when we will return hundred as the Alis score. At that time, we are taking minimum of our result and recursion call at that time. Bob will return minimum of hundred and his score. Can you explain how we are ensuring that Alice will get maximum I am a little bit confused. For bob min(result,100) in his case, we will end up with minimum score of bob
@Alpha-Code3 ай бұрын
The idea is in our function we are never calculating Bob's score. On Bob's turn we are simply returning the minimum for Alice given all the moves Bob can make. And on Alice's turn we are returning the maximum for Alice given all the moves that she can make. The function returns Alice's score given they both play optimally without calculating Bob's score at all, because the less points Alice gets the more Bob gets. So we can just focus on 1 score. So for example 2 you are referring to, the optimal play is Alice takes pile 1, Bob takes pile 2, Alice takes pile 3, Bob takes piles 4 and 5, and Alice takes pile 6. Alice's score is 1 + 3 + 100 from that = 104.