XOR in a range of a binary array
Given a binary array arr[] of size N and some queries. Each query represents an index range [l, r]. The task is to find the xor of the elements in the given index range for each query i.e. arr[l] ^ arr[l + 1] ^ … ^ arr[r]....
read more
Find a partition point in array to maximize its xor sum
Given an array a of size N. The task is to find an index ‘i’ (1 <= i <= N) such that (a[1] ^ … ^ a[i]) + (a[i+1] ^ … ^ a[N]) (x^y represents the xor value of x and y) is maximum possible....
read more
Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2
Given an array arr[] containing 2*N+2 positive numbers, out of which 2*N numbers exist in pairs whereas the other two number occur exactly once and are distinct. Find the other two numbers. Return in increasing order....
read more
XOR Linked List: Remove last node of the Linked List
Given an XOR linked list, the task is to delete the node at the end of the XOR Linked List....
read more
XOR of two numbers after making length of their binary representations equal
Given two numbers say a and b. Print their XOR after making the lengths of their binary representation equal by adding trailing zeros to the binary representation of smaller one. Examples :...
read more
Levelwise Alternating OR and XOR operations in Segment Tree
A Levelwise OR/XOR alternating segment tree is a segment tree, such that at every level the operations OR and XOR alternate. In other words at Level 1 the left and right sub-trees combine together by the OR operation i.e Parent node = Left Child OR Right Child and on Level 2 the left...
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
Minimum elements to be removed to make pairwise Bitwise XOR 0 or 1
Given an array X[] of length N. Then your task is to output the minimum number of elements needed to remove so that the Bitwise XOR of any pair is either 0 or 1....
read more
Quadruplet pair with XOR zero in the given Array
Given an array arr[] of N integers such that any two adjacent elements in the array differ at only one position in their binary representation. The task is to find whether there exists a quadruple (arr[i], arr[j], arr[k], arr[l]) such that arr[i] ^ arr[j] ^ arr[k] ^ arr[l] = 0. Here ^ denotes the bitwise xor operation and 1 ? i < j < k < l ? N.Examples:...
read more
Alternate XOR operations on sorted array
Given an array arr[] and two integers X and K. The task is to perform the following operation on array K times:...
read more
Check if rows of a Matrix can be rearranged to make Bitwise XOR of first column non-zero
Given a matrix mat[][] of size N * M, the task is to check if it is possible to rearrange the row elements of the matrix such that Bitwise XOR of the first column element is non-zero. If it is possible then print “Yes” else print “No”....
read more
Queries to find the XOR of an Array after replacing all occurrences of X by Y
Given an array arr[] consisting of N distinct integers and queries Q[][] of the type {X, Y}, the task for each query is to find the bitwise XOR of all the array elements after replacing X by Y in the array....
read more