Given an array arr[] consisting of N positive integers, the task is to find the sum of Bitwise AND of all possible triplets (arr[i], arr[j],… Read More

# Category Archives: Bit Magic

Given a positive integer N, the task is to count the number of different bases in which, when N is represented, the most significant bit… Read More

Given a Binary Tree consisting of N nodes, the task is to first compress the tree diagonally to get a list of integers and then,… 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

Given a positive integer N, the task is to check whether the given number N can be represented as the sum of the distinct powers… Read More

A bitset is an array of boolean values, but each boolean value is not stored separately. Instead, bitset optimizes the space such that each bool… Read More

Given a positive integer N, the task is to find the number of ways to represent N as Bitwise XOR of distinct positive integers less… Read More

Given an integer N, the task is to find the number of steps required to reduce the given number N to 1 by performing the… Read More

Given a positive integer N, the task is to count all numbers which are less than N and Bitwise AND of all such numbers with… Read More

Given an array arr[] consisting of N integers, the task is to find the maximum sum of any subsequence from the array having Bitwise AND… Read More

Given two integers A and B, the task is to count possible values of X that satisfies the condition A | X = B. Note:… Read More

Given a binary string, S of size N, the task is to check if it is possible to partition the string into disjoint subsequences equal… Read More

Given a Binary string, the task is to find the largest Prime Number possible by the decimal representation of a subsequence of the given binary… Read More

Given two integers A and B, the task is to check if there exists two integers P and Q over the range [1, A] and… Read More