## Calculate the number of set bits for every number from 0 to N

Given a non-negative integer N, the task is to find the count of set bits for every number from 0 to N. Examples: Input: N… Read More »

- Count total set bits in all numbers from 1 to n | Set 2
- Find the Majority Element | Set 3 (Bit Magic)
- Number formed by the rightmost set bit in N
- Count total set bits in all numbers from 1 to N | Set 3
- Count pairs with set bits sum equal to K
- Count Set-bits of number using Recursion
- Find a number containing N - 1 set bits at even positions from the right
- Count pairs of elements such that number of set bits in their OR is B[i]
- Smallest number greater or equals to N such that it has no odd positioned bit set

Given a non-negative integer N, the task is to find the count of set bits for every number from 0 to N. Examples: Input: N… Read More »

Given a distance K to cover, the task is to find the minimum steps required to cover the distance if steps can be taken in… Read More »

Given a positive integer N, the task is to count the total number of set bits in binary representation of all the numbers from 1… Read More »

Pre-requisite: Majority Element, Majority Element | Set-2 (Hashing) Given an array of size N, find the majority element. The majority element is the element that… Read More »

Given a number N. The task is to find the number of set bits in its binary representation using recursion. Examples: Input : 21 Output… Read More »

Given a positive integer N, the task is to count the sum of the number of set bits in the binary representation of all the… Read More »

Given an integer N, the task is to find an integer M formed by taking the rightmost set bit in N i.e. the only set… Read More »

Given an integer N, the task is to find the smallest integer X such that it has no odd position set and X ≥ N.… Read More »

Given a positive integer N, the task is to find a number which contains (N – 1) set bits in its binary form at every… Read More »

Given an array arr[] and an integer K, the task is to count the pairs whose sum of set bits is K Examples: Input: arr[]… Read More »

Given two arrays A[] and B[] of N elements each. The task is to find the number of index pairs (i, j) such that i… Read More »

Given a tree, and the weights of all the nodes and an integer x, the task is to find a node i such that weight[i]… Read More »

Given an array arr[] of positive integers, the task is to sort the array in decreasing order of count of set bits in binary representations… Read More »

Given two strings s1 and s2. The task is to take one character from first string and one character from second string and check if… Read More »