Skip to content

Category Archives: Bit Magic

Given two non-negative long integers, x and y given x <= y, the task is to find bit-wise and of all integers from x and… Read More
Given a number n, the task is to find the XOR from 1 to n. Examples :  Input : n = 6 Output : 7 //… Read More
Given a number n, the task is to check whether this number is a multiple of 4 or not without using +, -, * ,/… Read More
Given a number, the task is to multiply it with 10 without using multiplication operator?Examples:   Input : n = 50 Output: 500 // multiplication of… Read More
Given a number n, the task is to check whether it can be expressed as a sum of two or more consecutive numbers or not. Examples:  … Read More
Given a positive integer n, find count of positive integers i such that 0 <= i <= n and n+i = n^i  Examples :  Input… Read More
Given a number n, find length of the longest consecutive 1s in its binary representation.Examples :  Input : n = 14 Output : 3 The… Read More
Given a number, check whether it is even or odd. Examples :  Input: 2 Output: even Input: 5 Output: odd Recommended PracticeOdd Even ProblemTry It!… Read More
Two strings are said to be complete if on concatenation, they contain all the 26 English alphabets. For example, “abcdefghi” and “jklmnopqrstuvwxyz” are complete as… Read More
Given three variables, a, b and c, swap them without temporary variable.Example :   Input : a = 10, b = 20 and c = 30… Read More
Given an array of n unique integers where each element in the array is in range [1, n]. The array has all distinct elements and… Read More
Bitset is a container in C++ Standard Template Library for dealing with data at the bit level.  1. A bitset stores bits (elements with only… Read More
Consider a special family of Engineers and Doctors with following rules :  Everybody has two children. First child of an Engineer is an Engineer and… Read More
Given a number n, print first n positive integers with exactly two set bits in their binary representation.Examples :   Input: n = 3 Output: 3… Read More
Given a function rand50() that returns 0 or 1 with equal probability, write a function that returns 1 with 75% probability and 0 with 25%… Read More

Start Your Coding Journey Now!