Welcome to MindCipher, a social repository of the world's greatest brain teasers, logic puzzles and mental challenges.

Filtered by tag: bitwise

11 12 Bit Pair Swap
In one line of C or Java, how would you swap every pair of bits in a byte? That is, swap bits 0 and 1, 2 and 3, 4 and 5, 6 and 7. Example: 0110 1010 becomes 1001 0101.
Doable
6.0
4 Count The Bits
Write a function that counts the number of bits in an integer that are set to 1 that is linear in time complexity in the worst case, but sub-linear on average.
Hard
8.0
3 Power of 2 (Microsoft Interview)
Given any number n, using one line of C (using no external libraries or functions) code, determine if n is a power of 2. Return 1 if n is a power of 2 and 0 if not.
bitwise powers Submitted by Aakash
Doable
6.0