Given an array arr[] of N and Q queries consisting of a range [L, R]. the task is to find the bit-wise OR of all… Read More

# Category Archives: Bit Magic

Given a perfect binary tree of N nodes, with nodes having values from 1 to N as depicted in the image below and Q queries… Read More

Given an integer array arr[] of length N consisting of positive integers, the task is to minimize the number of steps required to reach the… Read More

Given an N * N matrix arr[][] consisting of non-negative integers, the task is to find the number of ways to reach arr[N – 1][N… Read More

Given a string of English alphabets. The task is, for every character in the string print its position in the English alphabets.Note: The characters in… Read More

Given an array arr[] of positive integers, the task is to sort the array in decreasing order of count of set bits in binary representations… Read More

Given an array arr[] of size N. The task is to find the number of pairs (arr[i], arr[j]) as cntAND, cntOR and cntXOR such that: … Read More

Given an array arr[] of non-negative integers, the task is to find an integer X such that (arr[0] XOR X) + (arr[1] XOR X) +… Read More

Given two integers A and B. The task is to choose an integer X such that (A xor X) + (B xor X) is the… Read More

Given an array arr[]. The task is to find an element from arr[] which has the maximum count of set bits.Examples: Input: arr[] = {10,… Read More

Just like base 2 Binary numeral system having 0s and 1s as digits, Ternary(Trinary) Numeral System is a base 3 number system having 0s, 1s… Read More

Given binary string str, the task is to find the largest power of 2 that divides the decimal equivalent of the given binary number. Examples: … Read More

Given two binary matrices, A[][] and B[][] of N×M. In a single operation, one can choose a sub-matrix (min of 2 rows and 2c columns)… Read More

Given three integer n, m and k. Find the element at kth position after repeating the given operation n number of times. In a single… Read More