Loved the way you explain concepts. It was funny when you said from "TLE" to "accepted" and from accepted to "wrong answer" (after a pause). Thanks! keep up the good work.
Yes , I will include it after a while. Till thn enjoy other playlists, there are many dp problems. ua-cam.com/play/PLKZaSt2df1gxtem7J8QqY8m2bHliz8mPt.html Here
sir in recursion approach , will we reach the "return 0" statement after loop? bcz, defenelty 1 will be factor to any number so we wont hit that return statement i think sir. please explain sir.
I got the idea of solving this question using tricky solution on the first go then came here to look other possible solutions. Is it ok to solve with that from the interview point of view.
Hey, can you please explain this? What if N is 4 and Alice picks 2 in the first call since 2 is in the range and it divides 4 as well? Then we are losing
I have a doubt. You used sqrt(N) for the factors max index limit... but if you see sqrt(N =6) , then we have two factors 2 and 3... but 3 is greater than sqrt(6).. can you explain why you omit 3 in such cases ? By this I mean, your examples are not using composite numbers... so can you explain how your solution works for that also ... thanks.
Can you just justify your approach with N = 4, Alice have option of taking either (1 or 2), assume Alice took 2 , now left is 2, Bob took 1 from it , now left is 1. here Alice have left with no option to choose hence loose , I know for 4 output is true but how come this is possible ?
can we use bottom to top approach here? like this: dp = [-1]*1001 def tabulation(self,N, dp): dp[1] = 0 for i in range(2, 1001): dp[i] = not dp[i-1] if i == N: return dp[N] return dp[N]
I understand that you have a good solution for this. But where can I learn what the problem is? After reading the leetcode description a few times through, I didn’t understand what is being asked. I didn’t understand the question until we got to the end of your video where you talk about stepping through the game. Then, it started to make sense. I think it’s better that way. A bunch of examples to understand the question is helpful.
Loved the way you explain concepts. It was funny when you said from "TLE" to "accepted" and from accepted to "wrong answer" (after a pause).
Thanks! keep up the good work.
Great Explaination bhaiya odd even waali to 🔥🔥
Didn't expect a O(1) solution, until I watched this explanation.
Love the way you explained | please explain to calculate time complexity as well
very well explained
This is how a problem optimization should be done from exponential to best time complexity
Thanks ❤️, please help me by sharing my channel
11:09 it's really funny at this point.
the way he said
made it funny lmao
Awesome explanation sir 😀😀
Thanks
Great explanation. Thank you for producing such quality content. Good luck.
Keep sharing please ☺️
would be good if you share the code in description too
Thankyou bhaiya for this session
Amazing Explanation!!!
nice
yeah....That's what i wanted. Respect++ when someone has proof.
Thanks
Nice explanation buddy! (Y)
Very well explained. Thanks!
great explanation sir
Thanks ☺️
Run the for loop for sqrt(n) we will get the same runtime and space .
I will have a look into question again
@@mohammadfraz yes sir plz do check and reply.
WoW u are my god
you could have explained top down DP as well
This was brilliant
Great explanation!! Thanks for sharing. Can you please include some union-find and bit manipulation problems?
Yes
Can you add video for some Theory how to approach dynamic problems.
Yes , I will include it after a while.
Till thn enjoy other playlists, there are many dp problems.
ua-cam.com/play/PLKZaSt2df1gxtem7J8QqY8m2bHliz8mPt.html
Here
sir in recursion approach , will we reach the "return 0" statement after loop? bcz, defenelty 1 will be factor to any number so we wont hit that return statement i think sir.
please explain sir.
I am not able to recall code now , you can remind me in the practice sessions please?
@@mohammadfraz when will those sessions happen sir?? Iam new to this channel sir .
@@sandeepnallala48 on every Sunday
I got the idea of solving this question using tricky solution on the first go then came here to look other possible solutions. Is it ok to solve with that from the interview point of view.
Yes it's acceptable
Nice
Thanks
Hey, can you please explain this?
What if N is 4 and Alice picks 2 in the first call since 2 is in the range and it divides 4 as well?
Then we are losing
it is given that both players will play optimally(which means using the best possible move to win). What you are saying is opposite of that
I have a doubt. You used sqrt(N) for the factors max index limit... but if you see sqrt(N =6) , then we have two factors 2 and 3... but 3 is greater than sqrt(6).. can you explain why you omit 3 in such cases ? By this I mean, your examples are not using composite numbers... so can you explain how your solution works for that also ... thanks.
Bro, I have the same doubt, did you come to know a solution for this?
@@gta6515 we are not ommiting 3 because when we took 2 we are also taking n/2 i.e. 6/2=3 which can be seen in code as well ....
This is really good
bhaiya please make videos on OS
Can you please explain bit manipulation problem?
Can you just justify your approach with N = 4,
Alice have option of taking either (1 or 2), assume Alice took 2 , now left is 2, Bob took 1 from it , now left is 1.
here Alice have left with no option to choose hence loose , I know for 4 output is true but how come this is possible ?
Bro, I have the same doubt, did you come to know a solution for this?
she will play optimally therefore she will choose 1 instead of 2
class Solution {
public:
bool divisorGame(int n) {
if(n%2==0)return true;
return false;
}
};
I just tried to make the dp table
found this
anyways gg
"From n^2 to wrong answer 😂😂"
Could anyone please tell if N=4, then why is not Alice choosing 2 as the value of x. Hereafter choosing 2 Alice would lose.
Hey I also have the same doubt, did you find the solution?
@@kashishbagga1032 It is mentioned, both players play optimally
can you provide code in java also
It's almost same , the Algo matters
Competitive
can we use bottom to top approach here?
like this:
dp = [-1]*1001
def tabulation(self,N, dp):
dp[1] = 0
for i in range(2, 1001):
dp[i] = not dp[i-1]
if i == N:
return dp[N]
return dp[N]
Yes buttom up can be used
If we use n=8 then from this last method we get wrong result
No I tested all methods n=8 works
You lost me here: @2:46 “if we choose i is equal to one”
Huh?
I understand that you have a good solution for this. But where can I learn what the problem is? After reading the leetcode description a few times through, I didn’t understand what is being asked.
I didn’t understand the question until we got to the end of your video where you talk about stepping through the game. Then, it started to make sense. I think it’s better that way. A bunch of examples to understand the question is helpful.