# Tag Archives: Algorithms-Bit Algorithms

## Bitwise Operations on Digits of a Number

Given a number N, the task is to perform the bitwise operations on digits of the given number N. The bitwise operations include: Finding the… Read More »

## Find a number containing N – 1 set bits at even positions from the right

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 »

## Find Multiples of 2 or 3 or 5 less than or equal to N

Given an integer . The task is to count all such numbers that are less than or equal to N which are divisible by any… Read More »

## Program to invert bits of a number Efficiently

Given a non-negative integer N. The task is to invert the bits of the number N and print the decimal equivalent of the number obtained… Read More »

## Find the missing element in an array of integers represented in binary format

Given N strings which represents all integers from 0 to N in binary format except any one. The task is to find the missing number.… 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 »

## Inserting M into N such that m starts at bit j and ends at bit i | Set-2

Given two 32-bit numbers, N and M, and two-bit positions, i and j. Write a method to insert M into N such that M starts… Read More »

## First element greater than or equal to X in prefix sum of N numbers using Binary Lifting

Given an array of N integers and a number X. The task is to find the index of first element which is greater than or… Read More »

## Maximum sum by adding numbers with same number of set bits

Given an array of N numbers, the task is to find the maximum sum that can be obtained by adding numbers with the same number… Read More »

## Count pairs with Bitwise AND as ODD number

Given an array of N integers. The task is to find the number of pairs (i, j) such that A[i] & A[j] is odd. Examples:… Read More »

## Check if bits in range L to R of two numbers are complement of each other or not

Given two non-negative numbers a and b and two values l and r. The problem is to check whether all bits at corresponding positions in… Read More »

## Iterative Segment Tree (Range Maximum Query with Node Update)

Given an array arr[0 . . . n-1]. The task is to perform the following operation: Find the maximum of elements from index l to… Read More »

## Print all the combinations of N elements by changing sign such that their sum is divisible by M

Given an array of N integers and an integer M. You can change the sign(positive or negative) of any element in the array. The task… Read More »

## Find i’th index character in a binary string obtained after n iterations | Set 2

Given a decimal number m, convert it into a binary string and apply n iterations, in each iteration 0 becomes “01” and 1 becomes “10”.… Read More »

## Bitwise OR (or | ) of a range

Given two integers L and R. Determine the bitwise OR of all the integers in the range [L, R] (both inclusive). Examples: Input: L =… Read More »