Bit Magic - Basic Articles
Given a number N, the task is to check whether the count of the set and unset bits in the given number are same. Examples:   Input:… Read More
Given two bracket sequences S1 and S2 consisting of ‘(‘ and ‘)’. The task is to check if the string obtained by concatenating both the… Read More
Given a number n and a value k, turn on the k’th bit in n.Examples:   Input: n = 4, k = 2 Output: 6 Input:… Read More
Given an array of N numbers and a number K. The task is to insert a number in the given array such that the bitwise… Read More
Given a number n and k (1 <= k <= 32), find the value of k-th bit in the binary representation of n. Bits are… Read More
We are a Number n and our task is to multiply the number by 4 using a bit-wise Operator. Examples:  Input : 4 Output :16… Read More
Baum Sweet Sequence is an infinite binary sequence of 0s and 1s. The nth term of the sequence is 1 if the number n has… Read More
You are given two positive integer n and k. You have to calculate the maximum possible XOR value of at most k-elements from 1 to… Read More
Given a positive integer n. The problem is to print numbers in the range 1 to n having first and last bits as the only… Read More
Given four positive integers, determine if there’s a rectangle such that the lengths of its sides are a, b, c and d (in any order).Examples… Read More
Given an array of size N. Find the number of pairs (i, j) such that XOR = 0, and 1 <= i < j <= N. Examples : … Read More
Given a non-negative number n and two values l and r. The problem is to count the number of set bits in the range l… 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
In Game of Nim, two players take turns removing objects from heaps or the pile of stones. Suppose two players A and B are playing the… Read More
Write an efficient program to count number of 1s in binary representation of an integer. Examples: Input : n = 6 Output : 2 Binary… Read More
Round 1: Phone Interview – Lasted for 45 minutes(Originally scheduled for 30 minutes). Questions involved about resume and projects. Understanding of data structures. Coding :… Read More
Given a positive integer n. The problem is to check whether only the first and last bits are set in the binary representation of n.Examples:  … Read More
Given a positive number n, count total bit in it.Examples:   Input : 13 Output : 4 Binary representation of 13 is 1101 Input : 183… Read More
Given two non-negative numbers m and n. Find the position of rightmost same bit in the binary representation of the numbers. Examples:   Input : m… Read More
Given a positive integer, write a function to find if it is a power of three or not. Examples:  Input : 3Output :YesInput :6Output :NoRecommended PracticeCheck… Read More