Leetcode 1025. Divisor Game

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

КОМЕНТАРІ • 68

  • @archivelib3379
    @archivelib3379 2 роки тому +1

    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.

  • @desihiphop4998
    @desihiphop4998 2 роки тому

    Great Explaination bhaiya odd even waali to 🔥🔥

  • @sauravchandra10
    @sauravchandra10 Рік тому

    Didn't expect a O(1) solution, until I watched this explanation.

  • @AnupamHaldkar
    @AnupamHaldkar 2 роки тому

    Love the way you explained | please explain to calculate time complexity as well

  • @megatronislive1331
    @megatronislive1331 Рік тому

    very well explained

  • @anishsuman1371
    @anishsuman1371 3 роки тому +1

    This is how a problem optimization should be done from exponential to best time complexity

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      Thanks ❤️, please help me by sharing my channel

  • @saumyaverma9581
    @saumyaverma9581 3 роки тому +2

    11:09 it's really funny at this point.

  • @satya1067
    @satya1067 3 роки тому +1

    Awesome explanation sir 😀😀

  • @sonalsrivastava9064
    @sonalsrivastava9064 4 роки тому +1

    Great explanation. Thank you for producing such quality content. Good luck.

  • @shantanusingh6699
    @shantanusingh6699 3 роки тому +1

    would be good if you share the code in description too

  • @ratnasanjay
    @ratnasanjay 2 роки тому

    Thankyou bhaiya for this session

  • @dheerjain2884
    @dheerjain2884 3 роки тому

    Amazing Explanation!!!

  • @lifehacks9450
    @lifehacks9450 4 роки тому +2

    nice

  • @chintankothari8835
    @chintankothari8835 4 роки тому

    yeah....That's what i wanted. Respect++ when someone has proof.

  • @rajatgupta-ld1wg
    @rajatgupta-ld1wg 3 роки тому

    Nice explanation buddy! (Y)

  • @lakshmiganaprasadantervedi3865
    @lakshmiganaprasadantervedi3865 3 роки тому

    Very well explained. Thanks!

  • @sandeepnallala48
    @sandeepnallala48 3 роки тому

    great explanation sir

  • @ayushbisht2689
    @ayushbisht2689 3 роки тому +1

    Run the for loop for sqrt(n) we will get the same runtime and space .

    • @mohammadfraz
      @mohammadfraz  3 роки тому +1

      I will have a look into question again

    • @ayushbisht2689
      @ayushbisht2689 3 роки тому

      @@mohammadfraz yes sir plz do check and reply.

  • @trinath6941
    @trinath6941 3 роки тому

    WoW u are my god

  • @prithvini04
    @prithvini04 3 роки тому

    you could have explained top down DP as well

  • @insofcury
    @insofcury 3 роки тому

    This was brilliant

  • @umber3117
    @umber3117 4 роки тому

    Great explanation!! Thanks for sharing. Can you please include some union-find and bit manipulation problems?

  • @RajeshJain-fs9jf
    @RajeshJain-fs9jf 4 роки тому +1

    Can you add video for some Theory how to approach dynamic problems.

    • @mohammadfraz
      @mohammadfraz  4 роки тому

      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

  • @sandeepnallala48
    @sandeepnallala48 3 роки тому

    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.

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      I am not able to recall code now , you can remind me in the practice sessions please?

    • @sandeepnallala48
      @sandeepnallala48 3 роки тому

      @@mohammadfraz when will those sessions happen sir?? Iam new to this channel sir .

    • @tejasjoshi1907
      @tejasjoshi1907 3 роки тому

      @@sandeepnallala48 on every Sunday

  • @BEEMohdArbazAli
    @BEEMohdArbazAli 3 роки тому

    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.

  • @kafeelazar5168
    @kafeelazar5168 3 роки тому

    Nice

  • @kashishbagga1032
    @kashishbagga1032 Рік тому

    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

    • @manpreetsinghrana7751
      @manpreetsinghrana7751 Рік тому

      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

  • @gauravmaithani4707
    @gauravmaithani4707 3 роки тому

    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.

    • @gta6515
      @gta6515 3 роки тому

      Bro, I have the same doubt, did you come to know a solution for this?

    • @agree.
      @agree. 3 роки тому

      @@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 ....

  • @RajeshJain-fs9jf
    @RajeshJain-fs9jf 4 роки тому

    This is really good

  • @banganties7
    @banganties7 Рік тому

    bhaiya please make videos on OS

  • @shwetakorulkar8666
    @shwetakorulkar8666 4 роки тому

    Can you please explain bit manipulation problem?

  • @ronaldkapoor9783
    @ronaldkapoor9783 3 роки тому +1

    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 ?

    • @gta6515
      @gta6515 3 роки тому

      Bro, I have the same doubt, did you come to know a solution for this?

    • @abhinavsingh9720
      @abhinavsingh9720 3 роки тому +1

      she will play optimally therefore she will choose 1 instead of 2

  • @debo01
    @debo01 3 роки тому

    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

  • @desihiphop4998
    @desihiphop4998 2 роки тому +1

    "From n^2 to wrong answer 😂😂"

  • @gta6515
    @gta6515 3 роки тому

    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.

    • @kashishbagga1032
      @kashishbagga1032 Рік тому

      Hey I also have the same doubt, did you find the solution?

    • @sauravchandra10
      @sauravchandra10 Рік тому

      @@kashishbagga1032 It is mentioned, both players play optimally

  • @bhavnamishra0327
    @bhavnamishra0327 3 роки тому

    can you provide code in java also

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      It's almost same , the Algo matters

  • @aman6561
    @aman6561 3 роки тому

    Competitive

  • @saravanan925
    @saravanan925 4 роки тому

    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]

  • @muskanjindal2921
    @muskanjindal2921 4 роки тому

    If we use n=8 then from this last method we get wrong result

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

    You lost me here: @2:46 “if we choose i is equal to one”
    Huh?

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

      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.