# Category Archives: Bit Magic

Given array of integers arr[] and queries[] of size N and Q, the task is to find the largest index for each query Q[i] such… Read More
Given an array B1[] and a binary array B2[] each of size N, the task is to rearrange array B1[] in a way such that… Read More
Given an array arr[] of N numbers (N ≤ 20), the task is to find the number of Derangements of the array where array elements… Read More
Given an array A[] of length N and an integer K, the task is to maximize the value of expression [i.j – K.(Ai | Aj)]… Read More
Given an array arr[] of size N. Find the minimum sum of the array after performing given operations any number of times: Select two different… Read More
Given a binary matrix mat[][]. The task is to find the maximum 1’s that can be obtained after flipping all the elements of exactly one… Read More
Given an array arr[] and an integer L which represents the number of bits to be considered in bit representation of an array element. The… Read More
Given an integer N count the number of values of X such that  X⊕N > N, where  ⊕ denotes bitwise  XOR operation Examples: Input: N =… Read More
Given a binary tree having N nodes, the task is to find the level having the maximum number of setbits. Note: If two levels have… Read More
Given an array arr (1-based indexing) of length N and an integer X, the task is to find and print all index ranges having a… Read More
Given an integer N denoting the size of an array and the bitwise AND (K) of all elements of the array. The task is to determine… Read More
Given a binary string  str, the task is to determine if string str can be converted into a palindrome in K moves. In one move… Read More
Given an array A of size n, the task is to check if the array can be sorted in increasing order, if the only operation… Read More
Given an integer N, the task is to print a permutation of numbers from 0 to N-1, such that: There is no duplicate element in… Read More
Over the network, messages are sent as data packets. Each data packet is a series of bytes (8bits = 1 byte). The task is to… Read More