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
Thank you! very helpful
great explanation
now i can write code from myself...
Great work Jatin Da
great video for a beginner like me ! thank you!
Thanks
Thanks sir ji👍
Pehli video se bohot paisa aaya....use n throw waale Ball pen se seedha trimax 😍
🤣🤣🤣🤣🤣
😂😂
Ameer toh bhai pehle se hi h
😂
Bas kbhi kbhi thoda kanjoosi dikha deta h😂😂
in else block count=log2(n); what does it significes???/
Count stores the number of bits required to release the number n.
Arre kya baat h
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
If you take n=220, log(n) would be 7.
Then n would be 220-128 = 92.
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.
@@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!
What is p in this code plz explain
P is your number which is smaller than n and also a power of 2
What about time complexity? Atleast you would have submitted and checked.
If you see the code every time I am changing n to n/2 hence complexity is O(logn base 2).