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

## Welcome to Interviewbit, help us create the best experience for you!

Currently, You are a:

College/University *
Enter the name of your college
Branch *
Year of completion *

College/University *
Enter the name of your college
Branch *
Year of completion *

Current Company *
Enter company name
Experience *

## You're all set!

Full name *
Email *

By creating an account, I acknowledge that I have read and agree to InterviewBitâ€™s Terms and Privacy Policy .

Email *

Go to Problems

Be a Code Ninja!

# Tricks with bits

• `x & (x-1)` will clear the lowest set bit of x
• `x & ~(x-1)` extracts the lowest set bit of x (all others are clear). Pretty patterns when applied to a linear sequence.
• `x & (x + (1 << n))` = x, with the run of set bits (possibly length 0) starting at bit n cleared.
• `x & ~(x + (1 << n))` = the run of set bits (possibly length 0) in x, starting at bit n.
• `x | (x + 1)` = x with the lowest cleared bit set.
• `x | ~(x + 1)` = extracts the lowest cleared bit of x (all others are set).
• `x | (x - (1 << n))` = x, with the run of cleared bits (possibly length 0) starting at bit n set.
• `x | ~(x - (1 << n))` = the lowest run of cleared bits (possibly length 0) in x, starting at bit n are the only clear bits.

## 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:44
Reverse Bits 225 23:50
Divide Integers 250 68:00
Different Bits Sum Pairwise 300 51:27
Bit tricks
Problem Score Companies Time Status
Min XOR value 200 37:42
Count Total Set Bits 200 63:18
Palindromic Binary Representation 200 59:59
XOR-ing the Subarrays! 200 33:00
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 19:28
Swap Bits 150 23:05
Free Mock Assessment
Help us know you better for the best experience
Current Employer *
Enter company name