Power of Two | Check if a number is Power of Two | Bit Manipulation Interview Questions

Sdílet
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

Komentáře • 38

  • @AkashGupta_youtube
    @AkashGupta_youtube Před 2 lety +3

    this logic is not working for 0

  • @kanhamishra1630
    @kanhamishra1630 Před 3 lety +5

    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.

  • @shubhamsood1406
    @shubhamsood1406 Před 3 lety +2

    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.

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

    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)

  • @vbv.bhardwaj

    left shift dekne aay atha bs pe itna sb btadia, tq bro

  • @deepak-pb2xt

    0 is the exception. Well, great content tbh. tysm

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

    n=0 dalne vala case kaise handle kare

  • @mickyman753
    @mickyman753 Před 2 lety

    rightmost set bit minus krne pr 0 ho jae toh power of two

  • @bradbale1510
    @bradbale1510 Před 3 lety

    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? :)

  • @Abhishekkumarnjw22-vf7cr
    @Abhishekkumarnjw22-vf7cr Před 9 hodinami

    Outstanding

  • @PankajYadav-kf4qf
    @PankajYadav-kf4qf Před 3 lety +9

    Sir you are doing great job for students those who can't afford online courses.I hope that your channel will grow fast

  • @faizan346
    @faizan346 Před 3 lety +3

    one correction it will give true even if the number is n = 0, which is not the power of 2

  • @0_0-0_0.
    @0_0-0_0. Před 3 lety +1

    bhai jisne bhi dislike kiya hai o bilkul nark jayega.

  • @vedantagarwal22
    @vedantagarwal22 Před 3 lety

    Great explanation sir , in all videos , thankyou !!!

  • @anishchauhan2647
    @anishchauhan2647 Před 3 lety

    thanks sir this helps me a lot

  • @ritiktwopointo2691
    @ritiktwopointo2691 Před 3 lety +2

    bits manipulation is really maical :)

  • @nishthagoyal5018
    @nishthagoyal5018 Před 3 lety

    Thankyou sir

  • @ShubhamKumar-km8pm
    @ShubhamKumar-km8pm Před rokem

    Thanks sir🔥

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

    we have to add this condition also;

  • @rahulbhatia3075
    @rahulbhatia3075 Před 3 lety

    Good explanation 🔥