## Python Slicing | Extract ‘k’ bits from a given position

How to extract ‘k’ bits from a given position ‘p’ in a number? Examples: Input : number = 171 k = 5 p = 2… Read More »

How to extract ‘k’ bits from a given position ‘p’ in a number? Examples: Input : number = 171 k = 5 p = 2… Read More »

Given a positive integer n. The problem is to print the numbers in the range 1 to n having bits in alternate pattern. Here alternate… Read More »

Given a non-negative number n and two values l and r. The problem is to count the number of unset bits in the range l… Read More »

Given a positive integer n, count the total number of set bits in binary representation of all numbers from 1 to n. Examples: Input: n… Read More »

Given two positive integers n and k. The problem is to check whether the bit at position k from the right in the binary representation… Read More »

You are given two positive number n and m. You have to find simply addition of both number but with a given condition that there… Read More »

XNOR gives the reverse of XOR if binary bit. First bit | Second bit | XNOR 0 0 1 0 1 0 1 0 0… Read More »

Given two arrays of positive integers. Select two sub-arrays of equal size from each array and calculate maximum possible OR sum of the two sub-arrays.… Read More »

Given two non-negative integers a and b. The problem is to find the position of the rightmost bit where a carry is generated in the… Read More »

Given two non-negative integers a and b. The problem is to check whether the two numbers differ at one bit position only or not. Examples:… Read More »

Given two numbers x and n, we need to multiply x with 2n Examples: Input : x = 25, n = 3 Output : 200… Read More »

Given two positive integers n and m. The problem is to check whether n is divisible by 2m or not without using arithmetic operators. Examples:… Read More »

Given an array A of n integers, say A1, A2, A3, …, An. You are given Q queries of the form [l, r]. The task… Read More »

Given a number n, the task is to generate n bit Gray codes (generate bit patterns from 0 to 2^n-1 such that successive patterns differ… Read More »