Skip to content

Category Archives: Bit Magic

Given a binary string S of length N, such that all 1s appear on the right. The task is to return the index of the… Read More
Pre-requisite: Binary Search Bitwise Binary Search algorithm is a modified version of Binary Search based on the following idea: Every number can be represented as… Read More
Given two binary strings str1 and str2 each of length N, the task is to split the strings in such a way that the sum… Read More
Given a binary array nums of length N, The task is to find all possible partitions in given array such that sum of count of… Read More
Given two positive integers A and B, perform one of the following operations only once to make the numbers equal.  Change the ith bit of… Read More
Given a binary string str of length N, the task is to find the number of setbits in the bitwise OR of all the K… Read More
Given an integer N, consider an array having elements in the range [0, N-1] such that the maximum Bitwise XOR of all adjacent pairs is… Read More
Given a binary matrix of size N * N, mat[][]. Value at cell (i, j) indicates what ith person says about jth person. A person… Read More
Given 3 integers A, B, and N the task is to perform alternate AND-OR operations on A and B, and then assign the result of… Read More
Given an array Arr of non-negative integers of size N, the task is to find the maximum possible OR between two numbers present in the… Read More
Given a number N and an integer K, the task is to set the Kth bit of the number N, i.e., if the Kth bit… Read More
Given a binary integer N, the task is to convert it into base 6. Note: The number of bits in N is up to 100. … Read More
Given an array arr[] containing N non-negative integers, the task is to find the maximum AND value among all the subsets having length K.  Examples: … Read More
Given an array arr[] of N integers, the task is to replace each element of Array with their rank according to Rightmost-Set Bit (RSB) in… Read More
Given an array arr[] of N non-negative integers and an integer P (1 ≤ P ≤ 30), which denotes the upper limit of any number… Read More