## Winner in the Rock-Paper-Scissor game using Bit manipulation

Two players are playing a series of games of Rock–paper–scissors. There are a total of N games played represented by an array arr[][] where arr[i]… Read More »

## Find the value of N XOR’ed to itself K times

Given two integer N and K, the task is to find the value of N XOR N XOR N XOR … XOR N (K times).… Read More »

## Find the minimum spanning tree with alternating colored edges

Given a graph with N nodes and M edges where each edge has a color (either black or green) and a cost associated with it.… Read More »

## Find the count of distinct numbers in a range

Given an array of size N containing numbers only from 0 to 63, and you are asked Q queries regarding it. Queries are as follows:… Read More »

## Convert Decimal To Hexa-Decimal including negative numbers

Given a number N in decimal format, the task is to convert it to the hexadecimal representation of N as a string. Negative numbers are… Read More »

## Find a number X such that (X XOR A) is minimum and the count of set bits in X and B are equal

Given two integers A and B, the task is to find an integer X such that (X XOR A) is minimum possible and the count… Read More »

## Set, Clear and Toggle a given bit of a number in C

Given a number N, the task is to set, clear and toggle the K-th bit of this number N. Setting a bit means that if… Read More »

## Find extra element in the second array

Given two arrays A[] and B[]. The second array B[] contains all the elements of A[] except for 1 extra element. The task is to… Read More »

## Maximum number of consecutive 1’s in binary representation of all the array elements

Given an array arr[] of N elements, the task is to find the maximum number of consecutive 1’s in the binary representation of an element… Read More »

## Maximum frequency of a remainder modulo 2i

Given an octal number N, the task is to convert the number to decimal and then find the modulo with every power of 2 i.e.… Read More »

## Maximum Sum of Products of two arrays by toggling adjacent bits

Given an integer array arr1 and a binary array arr2 of same size, the task is to find the maximum possible sum of products of… Read More »

## Maximum Bitwise OR pair from a range

Given a range [L, R], the task is to find a pair (X, Y) such that L ≤ X, Y ≤ R and (X |… Read More »

## Find closest integer with the same weight

Given a positive integer X the task is to find an integer Y such that: The count of set bits is Y is equal to… Read More »

## Rearrange array elements such that Bitwise AND of first N – 1 elements is equal to last element

Given an array arr[] of N positive integers, the task is to find an arrangement such that Bitwise AND of the first N – 1… Read More »

## Number of ways to split a binary number such that every part is divisible by 2

Given a binary string S, the task is to find the number of ways to split it into parts such that every part is divisible… Read More »