Company: Kotak_17oct
Difficulty: medium
Maximum product sales You are working in an e-commerce company. There are N products, numbered from 1 to N , and each product has 10^9 items in stock. Q customers visit the store one after another. Each customer does exactly one of the following three things: 1 R — buys one item of every product whose number lies in the range [1, R] (including both 1 and R ). 2 L — buys one item of every product whose number lies in the range [L, N] (including both L and N ). 3 C — buys nothing, and instead asks a question: among the products whose number is greater than or equal to C , which one has been bought the most times so far? If several products are tied for the most bought, the answer is the tied product whose number has the minimum difference from C , that is, the smallest number among them. No product has been bought before the first customer arrives. Answer every query of type 3 in the order in which the customers arrive. Function description Complete the function solve() . This function t