Bit Magic - Basic Articles
Given two numbers a and b. Find the minimum number of steps required to make the number of the set (1) and unset(0) bits equal… Read More
Given four integers A, B, C, and D, the task is to find the maximum sum of the given numbers by using the below operations… Read More
Given an array A consisting of N positive integers, the task is to calculate the maximum XOR of the subarray of size K consisting of… Read More
To swap two numbers without using a temporary variable, we have multiple approaches. In this article, we are going to learn how to swap two… Read More
In a party of N people, each person is denoted by an integer. Couples are represented by the same number. Find out the only single… Read More
Given an array arr[] of size N and an integer K, the task is to find the count of all the ordered pairs (i, j)… Read More
Given an integer N, the task is to find all possible integer M in the range [2, N] such that the bitwise OR of all… 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
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
Given an integer N., The task is to find the number of distinct permutations of length N, such that the bitwise AND value of each… Read More
Given an array a[] of size N and an integer K, the task is to find a value X in the range [0, K] which… Read More
Bit Rotation: A rotation (or circular shift) is an operation similar to a shift except that the bits that fall off at one end are… Read More
Given two binary matrices A[] and B[] of dimension N * M and a positive integer K, the task is to find the minimum number… Read More
Given a binary matrix mat[][] of dimensions M*N, the task is to check whether there exist T continuous blocks of 0s or not and at… Read More
Given an integer N, the task is to find the smallest number K such that bitwise AND of all the numbers in range [N, N-K]… Read More
Given a binary string S of size N, the task is to find the number of groups of 1s only in the string S. Examples:… Read More
Given an unweighted and undirected graph consisting of N nodes and two integers a and b. The edge between any two nodes exists only if… Read More
Bit Manipulation is a technique used in a variety of problems to get the solution in an optimized way. This technique is very effective from… Read More
Given an array arr[] of size N, the task is to check if any subarray of size K exists in the array or not, whose… 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