LeetCode 1140 - Stone Game II - Java

  Рет қаралды 541

Alpha-Code

Alpha-Code

Күн бұрын

Пікірлер: 7
@vineethm6930
@vineethm6930 3 ай бұрын
I was legit waiting for your video on this, thanks, as usual awesome explanation
@spinacker16
@spinacker16 3 ай бұрын
Medium problem? why not easy?
@sahebraojadhav9727
@sahebraojadhav9727 3 ай бұрын
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-Code
@Alpha-Code 3 ай бұрын
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.
@sahebraojadhav9727
@sahebraojadhav9727 3 ай бұрын
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-Code
@Alpha-Code 3 ай бұрын
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.
@sahebraojadhav9727
@sahebraojadhav9727 3 ай бұрын
@@Alpha-Code thank bro got it
LeetCode 962 - Maximum Width Ramp - Java
14:21
Alpha-Code
Рет қаралды 199
LeetCode 650 - 2 Keys Keyboard - Java
18:53
Alpha-Code
Рет қаралды 176
كم بصير عمركم عام ٢٠٢٥😍 #shorts #hasanandnour
00:27
hasan and nour shorts
Рет қаралды 8 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 25 МЛН
Auth - API - setting up auth (from scratch)
1:38:03
Andrew Cartwright
Рет қаралды 229
LeetCode 3133 - Minimum Array End - Java
19:23
Alpha-Code
Рет қаралды 92
Find if Array Can Be Sorted - Leetcode
13:13
ThinkOutsideTheBox
Рет қаралды 245
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 349 М.
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 1,8 МЛН
LeetCode 2501 - Longest Square Streak in an Array - Java
13:44