Power of Two | Check if a number is Power of Two | Bit Manipulation Interview Questions
Vložit
- čas přidán 6. 09. 2020
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we discuss the problem where we are required to check if a number is a power of two using bitwise operators and bit manipulation. In this problem,
1. You are given a number n.
2. You have to check whether it is a power of 2 or not.
To submit the question, click here: www.pepcoding.com/resources/d...
For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
#bitmanipulation #bits #leetcode
Have a look at our result: www.pepcoding.com/placements
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
this logic is not working for 0
A serious request to everyone who comments.. Please ask doubts.. You know it is a huge blessing to have Sumeet Sir guiding like this.. Please share the channel.. It's a request from me, one of his student.. Sir will also feel motivated to upload new new content everyday then.
Another approach is to count Set Bit and if set bit == 1, then it is a power of 2 else not a power of 2.
Sir completed 30 questions of dp foundation today, alag level ka confidence aa rha hai sir, Mazza alag aa rha hai pehli Baar padne mein, meine toh Apne next 4-5month pepcoding ke Naam kar diye, job thoda late kar lenge(2020 passout)
left shift dekne aay atha bs pe itna sb btadia, tq bro
0 is the exception. Well, great content tbh. tysm
n=0 dalne vala case kaise handle kare
rightmost set bit minus krne pr 0 ho jae toh power of two
Sir, im from mech branch. I've switched my career direction to IT and i am following pepcoding. Currently in 4th yr, unable to handle college subjects and minor project and coding together. was thinking to drop out(but bina degree ke job nahi), so just seeking suggestion as what to do? :)
Outstanding
Sir you are doing great job for students those who can't afford online courses.I hope that your channel will grow fast
one correction it will give true even if the number is n = 0, which is not the power of 2
bhai jisne bhi dislike kiya hai o bilkul nark jayega.
Great explanation sir , in all videos , thankyou !!!
thanks sir this helps me a lot
bits manipulation is really maical :)
Thankyou sir
Thanks sir🔥
we have to add this condition also;
Good explanation 🔥