Question: HandsOn > Max Queries There is an array a containing n integers. Let's define occ ( i , j , x ) as the number

HandsOn >Max Queries
There is an array a containing n integers.
Let's define occ(i,j,x) as the number of occurrences of x in the subarray from i to j. We define beauty (l,r,x) as the maximum value of occ(i,j,x) over all possible pairs )ij(r satisfying that the maximum element in the subarray from i to j is x.
You are also given q queries, each query contains three values , x) where )||r(105 and )x(105. The answer to each query is the beauty (l,r,x).
Find the sum of answers to all queries. Since the answer might be large return it modulo 10???9+7.
Input Format
The first line contains an integer, n, denoting the number of elements in a.
Each line i of the n subsequent lines (where a[i]q0i
 HandsOn >Max Queries There is an array a containing n integers.

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!