Bit Manipulation

Go to Problems

Bitwise and Logical Operators

  • Now that you have learnt about bitwise operators, you must have realized & is very different from &&. Similarily | is very different from ||
  • & or | work on integers performing the operator on each corresponding bits. However, && or || work on boolean values ( Any non zero value is true ) to produce a boolean result.

Example :

   2  |   1  = 3
   2  ||  1  = true
   2   &  1  =  0
   2  &&  1  = true 
  • Very similar to the fact that
    you can rewrite A = A + B as A += B,
    you can rewrite
    A = A | B as A |= B or
    A = A & B as A &= B

Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.

Bit Manipulation Problems

Bit play
Bit tricks
Bit array
Problem Score Companies Time Status
Single Number 275 11:53
Single Number II 275 39:22
lock
Topic Bonus
Bonus will be unlocked after solving min. 1 problem from each bucket