Counter Game || Bit Manipulation || HackerRank

Sdílet
Vložit
  • čas přidán 12. 08. 2020
  • Problem:www.hackerrank.com/challenges...
    Solution:github.com/jatin-verma-1999/C...

Komentáře • 23

  • @ritwikgarg
    @ritwikgarg Před 2 lety +1

    Thank you! very helpful

  • @anurudhsingh3397
    @anurudhsingh3397 Před 2 lety

    great explanation
    now i can write code from myself...

  • @shubhamchaudhary4225
    @shubhamchaudhary4225 Před 4 lety +1

    Great work Jatin Da

  • @FaisalKhan-ce2qu
    @FaisalKhan-ce2qu Před 3 lety

    great video for a beginner like me ! thank you!

  • @Vineetkumar-qz4wj
    @Vineetkumar-qz4wj Před 3 lety

    Thanks sir ji👍

  • @YashKrishan99
    @YashKrishan99 Před 4 lety +1

    Pehli video se bohot paisa aaya....use n throw waale Ball pen se seedha trimax 😍

  • @anjandey6089
    @anjandey6089 Před 3 lety

    in else block count=log2(n); what does it significes???/

    • @jatinverma3378
      @jatinverma3378  Před 3 lety

      Count stores the number of bits required to release the number n.

  • @vipul5529
    @vipul5529 Před 4 lety

    Arre kya baat h

  • @chrismdavis2009
    @chrismdavis2009 Před rokem

    Hello Jatin, I like the idea of your solution, but I think I find a logical issue with it.
    It works for the example of 132, but if we take another example, say n = 220(not a power of 2).
    if we take the log(n) as an int, we get 2(since the decimal is cut off).
    next, if we left shift 1 twice (1

    • @jatinverma3378
      @jatinverma3378  Před rokem

      If you take n=220, log(n) would be 7.
      Then n would be 220-128 = 92.

    • @jatinverma3378
      @jatinverma3378  Před rokem

      If you are confused about how log(n) is giving us a number of bits then you should Google it. It is simple you will understand it easily.

    • @chrismdavis2009
      @chrismdavis2009 Před rokem +1

      @@jatinverma3378 My apologies Jatin, I realized my calculation for log was base 10, not 2. I am getting the right answer, thank you and well done!

  • @Vineetkumar-qz4wj
    @Vineetkumar-qz4wj Před 3 lety

    What is p in this code plz explain

    • @jatinverma3378
      @jatinverma3378  Před 3 lety +1

      P is your number which is smaller than n and also a power of 2

  • @nickzesto6175
    @nickzesto6175 Před 3 lety

    What about time complexity? Atleast you would have submitted and checked.

    • @jatinverma3378
      @jatinverma3378  Před 3 lety

      If you see the code every time I am changing n to n/2 hence complexity is O(logn base 2).