## Minimum number of elements that should be removed to make the array good

Given an array arr[], the task is to find the minimum number of elements that must be removed to make the array good. A sequence… Read More »

## Find a positive number M such that gcd(N^M, N&M) is maximum

Given a number N, the task is to find a positive number M such that gcd(N^M, N&M) is the maximum possible and M < N.… Read More »

## Minimum number N such that total set bits of all numbers from 1 to N is at-least X

Given a number X, the task is to find the minimum number N such that total set bits of all numbers from 1 to n… Read More »

## Number of mismatching bits in the binary representation of two integers

Given two integers(less than 2^31) A and B. The task is to find the number of bits that are different in their binary representation. Examples:… Read More »

## Check whether bits are in alternate pattern in the given range | Set-2

Given a non-negative number and two values and . The problem is to check whether or not N has an alternate pattern in its binary… Read More »

## Number of ways to change the XOR of two numbers by swapping the bits

Given two binary strings s1 and s2. The XOR of them is X, the task is to find the number of ways to swap two-bit… Read More »

## Maximum set bit sum in array without considering adjacent elements

Given an array of integers arr[]. The task is to find the maximum sum of set bits(of the array elements) without adding the set bits… Read More »

## Subtraction of two numbers using 2’s Complement

Given two numbers and . The task is to subtract from by using 2’s Complement method. Note: Negative numbers represented as 2’s Complement of Positive… Read More »

## Number of elements greater than K in the range L to R using Fenwick Tree (Offline queries)

Prerequisites: Fenwick Tree (Binary Indexed Tree) Given an array of N numbers, and a number of queries where each query will contain three numbers(l, r… Read More »

## Check if a number has same number of set and unset bits

Given a number N, the task is to check whether the count of the set and unset bits in the given number are same. Examples:… Read More »

## Check whether the number has only first and last bits set | Set 2

Given a positive integer n, check whether only the first and last bits are set in the binary representation of n. Print ‘Yes’ or ‘No’.… Read More »

## Powers of 2 to required sum

Given an integer N, task is to find the numbers which when raised to the power of 2 and added finally, gives the integer N.… Read More »

## Number of ordered pairs such that (Ai & Aj) = 0

Given an array A[] of n integers, find out the number of ordered pairs such that Ai&Aj is zero, where 0<=(i,j)<n. Consider (i, j) and… Read More »

## Sum over Subsets | Dynamic Programming

Prerequisite: Basic Dynamic Programming, Bitmasks Consider the following problem where we will use Sum over subset Dynamic Programming to solve it. Given an array of… Read More »

## Print bitwise AND set of a number N

Given a number N, print all the numbers which are a bitwise AND set of the binary representation of N. Bitwise AND set of a… Read More »