##
Check whether all the bits are set in the given range
September 7, 2017

Given a non-negative number n and two values l and r. The problem is to check whether all the bits are set or not in… Read More »

September 7, 2017

Given a non-negative number n and two values l and r. The problem is to check whether all the bits are set or not in… Read More »

September 3, 2017

Given a number n, our task is to find all 1 to n bit numbers with no consecutive 1s in their binary representation. Examples:- Input… Read More »

August 31, 2017

Find the nth number whose binary representation is a palindrome. Do not consider the leading zeros, while considering the binary representation. Consider the 1st number… Read More »

August 30, 2017

Given a pack of 2^N cards (0 … 2^N – 1), shuffle it in N steps. At step k (0 < k < N) we… Read More »

August 21, 2017

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

Implement a space efficient algorithm to check First repeated character in a string without using any additional data structure in one traversal. Use additional data… Read More »

August 15, 2017

Given a number, change all bits at even positions to 0. Examples: Input : 30 Output : 10 Binary representation of 11110. Bits at Even… Read More »

August 9, 2017

Prerequisites : INT_MAX and INT_MIN in C/C++ and Applications. Arithmetic shift vs Logical shift Suppose you have a 32-bit system : The INT_MAX would be… Read More »

August 4, 2017

Given an array, write a program to add the minimum number(should be greater than 0) to the array so that the sum of array becomes… Read More »

August 3, 2017

A number N is given. We need to print its ‘K’th Least Significant Bit. Examples: Input : num = 10, k = 4 Output :… Read More »

Following are not allowed to use 1) Comparison Operators 2) String functions Examples: Input : num1 = 1233, num2 – 1233 Output : Same Input… Read More »

August 1, 2017

You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i… Read More »

July 31, 2017

Given a positive number you need to check whether it’s complement and the number are anagrams or not. Examples: Input : a = 4294967295 Output… Read More »

July 27, 2017

Given a number n, our task is to find all 1 to n bit numbers with no consecutive 1s in their binary representation. Examples: Input… Read More »

July 23, 2017

Given a number n. Find sum of all number upto n whose 2 bits are set. Examples: Input : 10 Output : 33 3 +… Read More »