Question: Array bitwise operations Given an array a , consisting of N integers. You are also given q queries on the array that you need to
Array bitwise operations
Given an array a consisting of integers. You are also given queries on the array that you need to perform on the array Each query is of the following two types:
Ir Find the or of array elements on the segment that means the value where is the bitwise OR operation.
Ir Apply for all i such that where is the bitwise XOR operation.
For each query of type print the result you get.
Function description Complete the solve function. The function takes parameters and returns a single integer denoting the answer to the question:
N Represents the length of the array
Represents the array
Represents the number of queries
queries. Represents a D array of size q with each row consisting of elements representing the queries
Input format for custom testing Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide bollerplate code.
The first line contains an integer denoting the length of the sting.
The second line contains spaceseparated integers representing the array
The third line contains a single integer denoting the number of queries
Next lines contain spaceseparated integers T I, r and denoting a query.
Output format Print a single integer for each type query.
Code in java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
