Skip to content

Category Archives: Bit Magic

Given two numbers x and y, and a range [l, r] where 1 <= l, r <= 32. The task is consider set bits of… Read More
A number ‘n’ is called Bleak if it cannot be represented as sum of a positive number x and set bit count in x, i.e.,… Read More
Given a number n, count number of n length strings with consecutive 1’s in them. Examples:  Input : n = 2 Output : 1 There… Read More
A bitset is an array of bool but each Boolean value is not stored separately instead bitset optimizes the space such that each bool takes… Read More
Binary Number is the default way to store numbers, but in many applications, binary numbers are difficult to use and a variety of binary numbers… Read More
Given an array arr[] of n numbers and a number K, find the number of subsets of arr[] having XOR of elements as KExamples : … Read More
Given a Binary Number as a string, print its 1’s and 2’s complements.  1’s complement of a binary number is another binary number obtained by… Read More
Given an set of positive integers. find the maximum XOR subset value in the given set. Expected time complexity O(n).Examples: Input: set[] = {2, 4,… Read More
The question is to find XOR of the XOR’s of all subsets. i.e if the set is {1,2,3}. All subsets are : [{1}, {2}, {3},… Read More
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted then the… Read More
Given an array “arr[0..n-1]” of integers, calculate sum of “arr[i] & arr[j]” for all the pairs in the given where i < j. Here &… Read More
A number is Sparse if there are no two adjacent 1s in its binary representation. For example 5 (binary representation: 101) is sparse, but 6… Read More
Given an array of integers. find the maximum XOR subarray value in the given array. Expected time complexity O(n). Examples:  Input: arr[] = {1, 2,… Read More
Given two integers, find XOR of them without using the XOR operator, i.e., without using ^ in C/C++. Examples :   Input: x = 1, y… Read More
Given an integer array of n integers, find sum of bit differences in all pairs that can be formed from array elements. Bit difference of… Read More

Start Your Coding Journey Now!