September 26, 2023
Latest:
TechInfo

# Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

## Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge ## Problem Statement

#### Return an array ‘B’ of length ‘Q’ such that ‘B[ i ]’ is the answer to the ‘i-th’ query.

##### For Example :
``````Let 'N' = 3, 'A' = [ 9, 1, 3 ], 'Q' = 2, queries = [ [ 0, 2, 1 ], [ 0, 1, 4 ] ].
The first query changes 'A' to [ 8, 0, 2 ], and the answer to it is 'A OR A OR A = 8 OR 0 OR 2 = 10'.
The second query changes 'A' to [ 12, 4, 2 ], and the answer to it is 'A OR A = 12 OR 4 = 12'.
Thus, the answer is [ 10, 12 ].
``````
Detailed explanation ( Input/output format, Notes, Images ) ##### Constraints :
``````1 <= 'T' <= 10
1 <= 'N, Q' <= 10^5
0 <= 'A[i], X' <= 10^9
0 <= 'L' <= 'R' < 'N'

Time Limit: 1 sec
``````
##### Sample Input 1 :
``````2
4 2
1 2 10 6
1 3 3
0 2 6
3 2
3 3 3
0 2 0
0 2 3
``````
##### Sample Output 1 :
``````13 15
3 0
``````
##### Explanation Of Sample Input 1 :
``````First test case:-
The first query changes 'A' to [ 1, 1, 9, 5 ], and the answer to it is 'A OR A OR A = 1 OR 9 OR 5 = 13'.
The second query changes 'A' to [ 7, 7, 15, 5 ], and the answer to it is 'A OR A OR A = 7 OR 7 OR 15 = 15'.
Thus, the answer is [ 13, 15 ].

Second test case:-
The first query does not change 'A'. Since all the elements of 'A' are '3', the bitwise OR of any range is '3'.
The second query changes 'A' to [ 0, 0, 0 ], making the bitwise OR of any range '0'.
Thus, the answer is [ 3, 0 ].
``````
##### Sample Input 2 :
``````2
4 2
1 2 3 4
0 3 101
0 2 65
5 3
101 19 69 111 37
0 3 8
2 4 10
0 4 1
``````
##### Sample Output 2 :
``````103 39
127 111 126`````` 6 digit code appear after 69 seconds.

Wait for Solution