# Category Archives: Bit Magic

Given a number N, the task is to find the number of zero’s in base K representation of the given number, where K > 1.… Read More
Given a positive integer N, the task is to find the minimum number of subtractions of power of 2 required to convert N to 0.… 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 array arr[] which contains N positive integers and an integer K. The task is to count all triplets whose XOR is equal to… Read More
Given two positive integers A and B. The task is to make them equal using minimum operations such that:  A = A + 1 (increase… Read More
For two integers X and Y are the tasks is to find the number of bits that are the same in their binary representation by… Read More
Given a binary array arr[] of size N and an integer K, the task is to check whether the binary array can be turned into… Read More
Given a binary string S of length N, consisting of 0s and 1s. The task is to count the number of triplet (i, j, k)… Read More
Given an array arr[] of size N, the task is to check if the array elements can be rearranged in a way such that the… Read More
Given a singly linked list, the task is to Count the pairs of nodes with greater Bitwise AND than Bitwise XOR. Examples: Input: list: 1->4->2->6->3Output:… Read More
Given a binary string str of size N, the task is to calculate the bitwise XOR of all substrings of str. Examples: Input: str =… Read More
Given a binary string s of length N, the task is to find the lexicographically smallest string using infinite number of swaps between 0’s and… Read More
Given an array arr that contains N positive Integers. Find the count of all possible pairs whose bit wise XOR value is greater than bit… Read More
Given an array arr that contains N positive Integers. Find the count of all possible pairs whose bitwise XOR value is greater than bitwise AND… Read More
Given a tree of having N nodes rooted at node 0, and an array val[] denoting the value at each node, the task is to… Read More