## Maximum Bitwise AND pair from given range

Given a range [L, R], the task is to find a pair (X, Y) such that L ≤ X < Y ≤ R and X… Read More »

## Iterating over all possible combinations in an Array using Bits

There arises several situations while solving a problem where we need to iterate over all possible combinations of an array. In this article, we will… Read More »

## Sum of bitwise AND of all subarrays

Given an array consisting of N positive integers, find the sum of bit-wise and of all possible sub-arrays of the array. Examples: Input : arr[]… Read More »

## Sum of XOR of all subarrays

Given an array containing N positive integers, the task is to find the sum of XOR of all sub-arrays of the array. Examples: Input :… Read More »

## Modify a binary array to Bitwise AND of all elements as 1

Given an array a[] consisting only 0 and 1. The task is to check if it is possible to transform the array such that the… Read More »

## Find the values of X and Y in the Given Equations

Given two numbers and . Find the values of X and Y in the equations. A = X + Y B = X xor Y… Read More »

## Find array using different XORs of elements in groups of size 4

Given an array q[] of XOR queries of size N (N is a multiple of 4) which describe an array of the same size as… Read More »

## Count of values of x <= n for which (n XOR x) = (n – x)

Given an integer n, the task is to find the number of possible values of 0 ≤ x ≤ n which satisfy n XOR x… Read More »

## Check if the binary representation of a number has equal number of 0s and 1s in blocks

Given an integer N, the task is to check if its equivalent binary number has the equal frequency of consecutive blocks of 0 and 1.… Read More »

## First and Last Three Bits

Given an integer N. The task is to print the decimal equivalent of the first three bits and the last three bits in the binary… Read More »

## Largest number less than X having at most K set bits

Given an integer X > 1 and an integer K > 0, the task is to find the greatest odd number < X such that… Read More »

## Minimum absolute difference between N and a power of 2

Given an integer N, the task is to find the minimum absolute difference between N and a power of 2. Examples: Input: N = 4… Read More »

## Represent n as the sum of exactly k powers of two | Set 2

Given two integers n and k, the task is to find whether it is possible to represent n as the sum of exactly k powers… Read More »

## Occurrences of a pattern in binary representation of a number

Given a string pat and an integer N, the task is to find the number of occurrences of the pattern pat in binary representation of… Read More »

## Smallest power of 2 which is greater than or equal to sum of array elements

Given an array of N numbers where values of the array represent memory sizes. The memory that is required by the system can only be… Read More »