Monday, 29 Nov 2021
Category: Bitwise-OR

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.Example:Input: X = 5, K = 1Output: 2Explanation: The first number is 2 as (2 + 5 = 2 | 5 )Input: […]

Given two positive integers X and K, the task is to find the Kth smallest positive integer (Y) such that the sum of X and Y is equal to Bitwise OR of X and Y, i.e. (X + Y = X | Y)Examples:Input: X = 5, K = 1Output: 2Explanation:Consider the smallest number as 2. […]

Split an array into subarrays with maximum Bitwise XOR of their respective Bitwise OR valuesGiven an array arr[] consisting of N integers, the task is to find the maximum Bitwise XOR of Bitwise OR of every subarray after splitting the array into subarrays(possible zero subarrays).Examples:Input: arr[] = {1, 5, 7}, N = 3Output: 7Explanation:The given […]

Find all possible pairs with given Bitwise OR and Bitwise XOR valuesGiven two positive integers A and B representing Bitwise XOR and Bitwise OR of two positive integers, the task is to find all possible pairs (x, y) such that x ^ y is equal to A and x | y is equal to B.Examples:Input: […]

Bitwise OR of Bitwise AND of all subarrays of an arrayGiven an array arr[] consisting of N positive integers, the task is to find the Bitwise OR of Bitwise AND of all subarrays of the given array.Examples:Input: arr[] = {1, 2, 3}Output: 3Explanation:Following are the Bitwise AND of all possible subarrays are:{1}, Bitwise AND is […]

Count pairs with odd Bitwise XOR that can be removed and replaced by their Bitwise ORGiven an array arr[] consisting of N integers, the task is to count the number of pairs whose Bitwise XOR is odd, that can be removed and replaced by their Bitwise OR values until no such pair exists in the […]