Salesforce OA | Please help me with this question
Anonymous User
1403

You are given an array of n elements, initially all element are zero. You have given a 'Q' queries need to be performed. Each query contains three integers l, r, and x and you need to change arr[i] to arr[i] | x in the given range of l <= i <= r.

Input:
N=3, Q=2, Queries=[[1, 3, 1],[1, 3, 2]]
Ouput : [3, 3, 3]
Constraints : 
1 <= N <= 10^5
1 <= Q <= 10^5
1 <= l,r <= N
1 <= x <= 10^5
  • Can anyone solve this in O(n).
Comments (10)