Given a number N which is a power of 2. Calculate total number of set bits from 1 to N-1. Examples : Input : N = 8 Output : 12 Explanation : Read more →
Bit Magic
6 postsYou are given a positive integer n, and an array a of positive integers. Find number of such pairs (i,j) such that i<j and ai & aj ≥ ai ^ aj, where Read more →
Given an array of size N, print the index of the distinct element from the array, provided the array has only one distinct element and rest other elements are same. Examples: Input: Read more →
Given an array arr[] of n positive integers and q queries, in which each query have an integer k. For each query, the task is to output the minimum size of subarray Read more →
Given an array of N elements, the task is to find the minimum value of K such that Bitwise XOR of K with all array elements is minimum Input: arr[] 16 12 Read more →
Two numbers: m and n are given. The size of these numbers is 32-bit long. You are also given two-bit positions: i and j. You have to set all bits between i Read more →