Question: AND XD 0 8 Queries You have a large amount of data you need to store. You are interested in knowing some details about the

AND XD08 Queries You have a large amount of data you need to store. You are interested in knowing some details about the structure of your data in binary in order to optimize how it is stored. In particular, you are interested in the bitwise AND of certain contiguous subarrays of its elements. To do so, you try to answer some queries. You're given an array A of n numbers. There are q queries that you need to answer. Each query is of the form Irst. For each contiguous subarray in the range I to r (inclusive), we define p as the bitwise AND of all its elements. The answer to each query is the number of contiguous subarrays of size s in this range that has p 2 t. For example, given n =6 numbers [21,,29,31,15,13,5] and a query 4627, the range is [15,13,5]. In this, we need to find for how many subarrays of size 2 the value of p >7. The subarrays of size 2 are [15,13] and [13,5]. These have p values of 13 and 5. Therefore the output should be 1 since there is 1 subatray of size 2(115,13) having p >7. Function Description Complete the fnction andQueries in the editor below. andQueries has the following parameter(s): int numbers[n]: an array of integers int gueries[g][4]: a 2d array of integers where queries[i) contains the i" query.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!