Question: u can do with any language i prefer python 3.8 Problem Description Given an integer array A containing N integers. In one operation we can

u can do with any language i prefer python 3.8 Problem DescriptionGiven an integer array A containing N integers. In one operation weu can do with any language

i prefer python 3.8

Problem Description Given an integer array A containing N integers. In one operation we can select any one element from the array A and increment it by 1. You need to answer Q queries in each query you are given two integer Land R you need to tell the minimum number of operation you need to perform such that the subarray of A starting index L and ending at index R contains at least one pair of elements whose bitwise AND is strictly greater than zero. NOTE: Each query is independenti.e for each query consider the given array A to answer it. Problem Constraints 2 = 2 Input Format First argument is an integer array A of size N. Second argument is a 2D integer array B of size Q x 2 where (B[i][0), B[b][1]) denotes the L, R for ith query. Output Format Return an integer array of size Q denoting the answer to each queries. NOTE: Return the answers to the queries in the order, in which the queries occur in the input Example Input Input 1: A = [1, 2, 3] B = [[1, 2] Example Input Input 1: A = [1, 2, 3] B = [[1, 2] [0, 1] [e, 2] ) Input 2: A = [2, 2, 2) B = [[@, 2] Example Output Output 1: [0, 1, 0) Output 2: [@] Example Explanation Explanation 1: A = [1, 2, 3] Query 1: L = 1 and R = 2 50 subarray(1 : 2] = [2, 3] => We don't need to increment any element as 2 & 3 > .. Query 2: L = 0 and R = 1 so subarray[e: 1] = [1, 2] => If we increment 1 then subarray will be [2, 2] and 2 & 2 > 0. Query 3: L = 0 and R = 2 so subarray[@ : 2] = [1, 2, 3] => We don't need to incresent any element as 2 & 3 > . Explanation 2: Query 1: L = and R = 2 so subarray[: 2] = [2, 2, 2] => We don't need to increment any element as 2 8 2 > 0

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 Databases Questions!