Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

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
Problem Score Companies Time Status
Number of 1 Bits 200 8:47
Trailing Zeroes 200 14:49
Reverse Bits 225 23:50
Divide Integers 250 68:04
Different Bits Sum Pairwise 300 51:29
Bit tricks
Problem Score Companies Time Status
Min XOR value 200 37:42
Count Total Set Bits 200 63:58
Palindromic Binary Representation 200 60:51
XOR-ing the Subarrays! 200 33:32
Bit array
Problem Score Companies Time Status
Single Number 275 11:53
Single Number II 275 39:22

Problem Score Companies Time Status
Bit Flipping 200 21:30
Swap Bits 150 26:17
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+33 *
+33
Change Number
Phone Number *
OTP will be sent to this number for verification
+33 *
+33
Change Number
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *