TRILOGY INNOVATIONS EXAM ANSWERS | CODING SOLUTIONS | Subarrays AND OR

preview_player
Показать описание
Subarrays AND OR

Problem Description

Given an array A of N integers and an array B of Q queries and updates. There are three type of queries which are as follows:

(i) 11 rv: Initialize every element with v in the range [l, r].

(ii) 21rv: Change every element x in the range [l, r] to x OR v

(iii) 31r0: Find the sum of bitwise AND of all the subarrays [11, r1] such that 11 and r1=r

You have to return the answer for each query of type 3 in the order in which they are asked

Input Format

The first argument is the array A.
Рекомендации по теме