Bitwise operations on Subarrays of size K
Given an array arr[] of positive integers and a number K, the task is to find the minimum and maximum values of Bitwise operation on elements of subarray of size K....
read more
Minimum XOR of OR and AND of any pair in the Array
Given an array arr[] of N positive integers the task is to find the minimum value of Bitwise XOR of Bitwise OR and AND of any pair in the given array....
read more
Assign other value to a variable from two possible values
Suppose a variable x can have only two possible values a and b, and you wish to assign to x the value other than its current one. Do it efficiently without using any conditional operator.Note: We are not allowed to check current value of x. Examples:...
read more
Number of subsets with same AND, OR and XOR values in an Array
Given an array arr[] of size N consisting of non-negative integers, the task is to find the number of non-empty subsets of the array such that the bitwise AND, bitwise OR and bitwise XOR values of the subsequence are equal to each other....
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 | Y) is maximum among all the possible pairs then print the bitwise OR of the found pair.Examples:...
read more
K-th smallest positive integer having sum with given number equal to bitwise OR with given number
Given two positive integers X and K, the task is to find the K-th smallest positive integer Y, such that X + Y = X | Y, where | denotes the bitwise OR operation....
read more
Leftover element after performing alternate Bitwise OR and Bitwise XOR operations on adjacent pairs
Given an array of N(always a power of 2) elements and Q queries.Every query consists of two elements, an index, and a value… We need to write a program that assigns value to Aindex and prints the single element which is left after performing the below operations for each query:...
read more
Maximizing Profits using Bitwise OR
Given two integers N, K and two integer arrays weights[] and profits[] each of size N where weights[i] is the weight associated with the ith item and profit[i] is the profit associated with the ith item. Maximize the profit by selecting a subset of items such that the bitwise OR of their weights is less than or equal to the given threshold K....
read more
Maximum Strings Concatenation
Given an array of strings, where each string consists of lowercase characters from a to j. You need to find the maximum number of strings that can be concatenated together such that the resulting string can be made out of exactly k distinct characters....
read more
Minimize Array Sum by replacing pairs with (X, Y) keeping their bitwise OR same
Given an array arr[] of size N. Find the minimum sum of the array after performing given operations any number of times:...
read more
Count distinct Bitwise OR of all Subarrays
Given an array A of non-negative integers, where . The task is to count number of distinct possible results obtained by taking the bitwise OR of all the elements in all possible Subarrays....
read more
Maximize the bitwise OR of an array
Given an array of N integers. The bitwise OR of all the elements of the array has to be maximized by performing one task. The task is to multiply any element of the array at-most k times with a given integer x.Examples :...
read more