Company: Cisco
Difficulty: medium
1. Online Occurrences You are given an array a of length n. It is given that the beauty(l, r) is defined as the maximum integer x that appears at least x times in the subarray from l to r (or zero if no such integer exists). You are given q queries where each query contains two integers l and r such that 1 ≤ l ≤ r ≤ n. The answer to each query is the beauty(l, r). You have to find the answer to the queries in an online way. This means that for the i th query, add the sum of answers over all previous queries to both l and r, then do the following: l = l mod n + 1. r = r mod n + 1. if l > r, then swap(l, r). Find the sum of answer to all q queries. Since the answer can be large, return it modulo 10 9 +7. Function description Complete the get_ans function in the editor below. It has the following parameter(s): Name Type Description [unclear] The size of the array.