# Category Archives: Bit Magic

Given a binary matrix M[][] of dimensions N x N, the task is to make every pair of adjacent cells in the same row or… Read More
Given two arrays arr1[] of size M and arr2[] of size N, the task is to find the sum of bitwise AND of each element… Read More
Given an array Arr[] of N ( 1 ≤ N ≤ 105)integers, the task is to generate an array B[] consisting of N non-zero elements,… Read More
Given an integer N, the task is to find the decimal value of the binary string formed by concatenating the binary representations of all numbers… Read More
Given an integer N, the task is to find the minimum number of coins of the form 2i required to make a change for N… Read More
Given two numbers A and B, the task is to count the number of set bits in A and B and flip the bits of… Read More
Given two integers X and S, the task is to construct a sequence of distinct integers from the range [1, X] such that the sum… Read More
Given a 2D matrix mat[][] of size N * M, the task is to find the median of Bitwise XOR of all possible submatrices from… Read More
Given two integers N and K, the task is to find the count of numbers up to N having K-th bit set. Examples: Input: N… Read More
Given two positive integers N and K, the task is to count the numbers from the range [1, N] whose Kth bit from the right,… Read More
Given an array arr[] of size N, the task is to find all the triplets (i, j, k) such that replacing the elements of the… Read More
Given a numeric string S, the task is to find the longest non-empty substring that can be made palindrome. Examples: Input: S = “3242415”Output: 5Explanation:… Read More
Given an array of integers A[] consisting of N integers, find the number of triples of indices (i, j, k) such that A[i] & A[j]… Read More
Given an integer N, the task is to find the Bitwise XOR of all odd numbers in the range [1, N]. Examples:   Input: 11Output: 2Explanation:… Read More
Given an array arr[] of length N, the task for every array element is to print the sum of its Bitwise XOR with all other… Read More