# Tag Archives: setBitCount

## Maximum set bit count from pairs of integers from 0 to N that yields a sum as N

Given an integer N, the task is to find the maximum frequency of set bits among all pairs of integers from 0 to N that… Read More »

## Maximize count of set bits in a root to leaf path in a binary tree

Given a binary tree, the task is to find the total count of set bits in the node values of all the root to leaf… Read More »

## First number to leave an odd remainder after repetitive division by 2

Given two integers A and B, the task is to print the integer among the two, which will be converted to an odd integer by… Read More »

## Generate an Array such with elements maximized through swapping bits

Given an array arr[], the task is to generate a modified array such that all its elements are maximized by swapping of bits.Examples:   Input: arr[]… Read More »

## Count of binary strings of length N with even set bit count and at most K consecutive 1s

Given two integers N and K, the task is to find the number of binary strings of length N having an even number of 1’s… Read More »

## Find all powers of 2 less than or equal to a given number

Given a positive number N, the task is to find out all the perfect powers of two which are less than or equal to the… Read More »

## Absolute difference between set and unset bit count in N

Prerequisite: Bitset function in STL library Given a number N, the task is to find the absolute difference of the number of set and unset… Read More »

## Number formed by flipping all bits to the left of rightmost set bit

Given an integer N, the task is to flip all the bits to the left of rightmost set bit and print the number generated. Examples:… Read More »

## Maximum number of 0s that can be flipped such that Array has no adjacent 1s

Given a binary array arr, the task is to find the maximum number of 0s that can be flipped such that the array has no… Read More »

## Minimum bit flips such that every K consecutive bits contain at least one set bit

Given a binary string S, and an integer K, the task is to find the minimum number of flips required such that every substring of… Read More »

## C program to count zeros and ones in binary representation of a number

Given a number N, the task is to write C program to count the number of 0s and 1s in the binary representation of N.… Read More »

## Maximum number of set bits count in a K-size substring of a Binary String

Given a binary string S of size N and an integer K. The task is to find the maximum number of set bit appears in… Read More »

## Count of even and odd set bit Array elements after XOR with K for Q queries

Given an array arr of N elements and another array Q containing values of K, the task is to print the count of elements in… Read More »

## Count of pairs in an Array with same number of set bits

Given an array arr containing N integers, the task is to count the possible number of pairs of elements with the same number of set… Read More »

## Count of pairs having bit size at most X and Bitwise OR equal to X

Given a number X, calculate number of possible pairs (a, b) such that bitwise or of a and b is equal to X and number… Read More »