Given two positive integers N and X, the task is to construct N positive integers having Bitwise XOR of all these integers equal to K.… Read More

# Category Archives: Bit Magic

Given a positive integer N, the task is to find the number that can be obtained by flipping consecutive set bits starting from the LSB… Read More

Given an N-ary Tree consisting of N nodes valued from 1 to N, an array arr[] consisting of N positive integers, where arr[i] is the… Read More

Given an array arr[] consisting of N integers, the task is to find an integer K, not having more than maximum bits present in any… Read More

Given an array arr[] of size N, the task is to find the bitwise AND of all possible unordered pairs present in the given array.… Read More

Given two integers X and Y, representing Bitwise XOR and Bitwise AND of two positive integers, the task is to calculate the Bitwise OR value… Read More

Given an integer N, the task is to reduce the value of N to 0 by performing the following operations minimum number of times: Flip… Read More

Given an integer N, the task is to find the Nth natural number with exactly two set bits. Examples: Input: N = 4Output: 9Explanation: Numbers… Read More

Given an array arr[] of length N, the task is to find the count of array indices such that removing an element from these indices… Read More

Given two integers X and Y, the task is to find the two integers having sum X and Bitwise XOR equal to Y. Examples: Input:… Read More

Given a binary matrix, mat[][] of dimensions N * M, the task is to maximize the count of rows consisting only of equal elements by… Read More

Given two positive integers A and B, the task is to flip the common set bitsin A and B. Examples: Input: A = 7, B… Read More

Given binary string str, the task is to find the minimum number of characters required to be flipped to make all 1s in right and… Read More

Given a positive integer N, the task is to find the total count of set bits by performing Bitwise XOR on all possible adjacent elements… Read More

Given an integer N, the task is to find all non-negative pairs (A, B) such that the sum of Bitwise OR and Bitwise AND of… Read More