##
Sum of numbers with exactly 2 bits set
July 23, 2017

Given a number n. Find sum of all number upto n whose 2 bits are set. Examples: Input : 10 Output : 33 3 +… Read More »

July 23, 2017

Given a number n. Find sum of all number upto n whose 2 bits are set. Examples: Input : 10 Output : 33 3 +… Read More »

July 18, 2017

Given a number maximize it by swapping bits at it’s extreme positions i.e. at first and last position, second and second last position and so… Read More »

July 17, 2017

Given two non-negative numbers n and m. The problem is to find the smallest number having n number of set bits and m number of… Read More »

July 13, 2017

Given a non-negative number n. Find the position of rightmost unset bit in the binary representation of n, considering the last bit at position 1,… Read More »

July 12, 2017

The Problem This problem is named after Flavius Josephus a Jewish historian who fought against the Romans. According to Josephus him and his group of… Read More »

July 10, 2017

Given two non-negative numbers n and m. The problem is to find the largest number having n number of set bits and m number of… Read More »

July 9, 2017

Parity of a number refers to whether it contains an odd or even number of 1-bits. The number has “odd parity”, if it contains odd… Read More »

July 7, 2017

Given two numbers you are required to check whether they are anagrams of each other or not in binary representation. Examples: Input : a =… Read More »

July 6, 2017

Given a non-negative number n and two values l and r. The problem is to unset the bits in the range l to r in… Read More »

July 5, 2017

Given a non-negative number n and two values l and r. The problem is to toggle the bits in the range l to r in… Read More »

July 4, 2017

Given a non-negative number n. The problem is to toggle the last m bits in the binary representation of n. A toggle operation flips a… Read More »

July 3, 2017

Given a number n. The problem is to efficiently check whether n is a multiple of 4 or not without using arithmetic operators. Examples: Input… Read More »

Given an array of n integers. Find out number of pairs in array whose XOR is odd. Examples: Input : arr[] = { 1, 2,… Read More »

July 1, 2017

Given a non-negative number n. The problem is to set the rightmost unset bit in the binary representation of n. If there are no unset… Read More »

June 30, 2017

Given a positive integer ‘n’ having ‘x’ number of set bits in its binary representation. The problem is to find the previous smaller integer(greatest integer… Read More »