# Category Archives: Bit Magic

## Print all the leaf nodes of Binary Heap

Given an array of N elements which denotes the array representation of binary heap, the task is to find the leaf nodes of this binary… Read More »

## Minimize K whose XOR with given array elements leaves array unchanged

Given an array of N elements, the task is to find the minimum value of K such that Bitwise XOR of K with all array… Read More »

## Count of elements which cannot form any pair whose sum is power of 2

Given an array arr[] of length N, the task is to print the number of array elements that cannot form a pair with any other… Read More »

## Maximum OR value of a pair in an Array | Set 2

Given an array arr[] of N positive elements, the task is to find the maximum bitwise OR value of a pair from the given array.Examples:… Read More »

## Count of binary strings of given length consisting of at least one 1

Given an integer N, the task is to print the number of binary strings of length N which at least one ‘1’. Examples: Input: 2… Read More »

## Check whether the binary equivalent of a number ends with given string or not

Given a positive integer N, the task is to check whether the binary equivalent of that integer ends with a given string str or not. Print… Read More »

## Count of pairs whose bitwise AND is a power of 2

Given an array arr[] of N positive integers. The task is to find the number of pairs whose Bitwise AND value is a power of… Read More »

## Find elements in a given range having at least one odd divisor

Given two integers N and M, the task is to print all elements in the range [N, M] having at least one odd divisor. Examples:… Read More »

## BCD or Binary Coded Decimal

Binary Coded Decimal, or BCD, is another process for converting decimal numbers into their binary equivalents. It is a form of binary encoding where each… Read More »

## Find all possible ways to Split the given string into Primes

Given string str that represents a number. The task is to find all possible ways to split the given string such that each segment is… Read More »

## Count of binary strings of length N with even set bit count and at most K consecutive 1s

Given two integers N and K, the task is to find the number of binary strings of length N having an even number of 1’s… Read More »

## Minimum flips required in a binary string such that all K-size substring contains 1

Given a binary string str of size N and a positive integer K, the task is to find the minimum number of flips required to… Read More »

## Count of lists which are not a subset of any other given lists

Given N lists of strings, the task is to find the count of lists which are not a sublist of any other given lists. Examples:… Read More »

## Count of total bits toggled/flipped in binary representation of 0 to N

Given an integer N, the task is to find the total number of bits toggled to obtain all numbers from 0 to N sequentially.Examples: Input:… Read More »

## Construct the Array using given bitwise AND, OR and XOR

Given Bitwise AND, OR, and XOR of N elements of an array denoted by a, b, c. The task is to find the elements of… Read More »