##
Josephus Problem Using Bit Magic
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 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 »

The problem is to convert the given binary number (represented as string) to its equivalent octal number. The input could be very large and may… Read More »

June 29, 2017

Given two numbers m and n. Find the position of rightmost different bit in binary representation of numbers. It is guaranteed that such a bit… Read More »

June 28, 2017

Given a array such that all its terms is either 0 or 1.You need to tell the number represented by a subarray a[l..r] is odd… Read More »

June 27, 2017

Given a number n. The problem is to check whether every bit in the binary representation of the given number is set or not. Here… Read More »