## Count number of step required to reduce N to 1 by following certain rule

Given a positive integer . Find the number of steps required to minimize it to 1. In a single step N either got reduced to… Read More »

## Count number of bits changed after adding 1 to given N

Given an integer . The task is to find the number of bits changed after adding 1 to the given number. Examples: Input : N… Read More »

## XOR of all elements of array with set bits equal to K

Given an array of integers and a number K. The task is to find the XOR of only those elements of the array whose total… Read More »

## Count pairs in an array such that both elements has equal set bits

Given an array arr with unique elements, the task is to count the total number of pairs of elements that have equal set bits count.… Read More »

## Maximum number of contiguous array elements with same number of set bits

Given an array with n elements. The task is to find the maximum number of contiguous array elements which have the same number of set… Read More »

## Number of mismatching bits in the binary representation of two integers

Given two integers(less than 2^31) A and B. The task is to find the number of bits that are different in their binary representation. Examples:… Read More »

## Count ordered pairs of positive numbers such that their sum is S and XOR is K

Given a sum and a number . The task is to count all possible ordered pairs (a, b) of positive numbers such that the two… Read More »

## Number of values of b such that a = b + (a^b)

Given an integer . Find the number of solutions of which satisfies the equation: a = b + (a^b) Examples: Input: a = 4 Output:… Read More »

## Print the number of set bits in each node of a Binary Tree

Given a Binary Tree. The task is to print the number of set bits in each of the nodes in the Binary Tree. Recommended: Please… Read More »

## Hamming distance between two Integers

Given two integers, the task is to find the hamming distance between two integers. Hamming Distance between two integers is the number of bits which… Read More »

## Check whether bits are in alternate pattern in the given range | Set-2

Given a non-negative number and two values and . The problem is to check whether or not N has an alternate pattern in its binary… Read More »

## Program to invert bits of a number Efficiently

Given a non-negative integer N. The task is to invert the bits of the number N and print the decimal equivalent of the number obtained… Read More »

## Check if a number has same number of set and unset bits

Given a number N, the task is to check whether the count of the set and unset bits in the given number are same. Examples:… Read More »

## Count set bits in an integer

Write an efficient program to count number of 1s in binary representation of an integer. Examples : Input : n = 6 Output : 2… Read More »