The question states that we are given an empty list and 10^5 queries.For each query, we have two integers a and b.a can only be 1, 2 or 3.
if a=1, then append element b in the list.
if a=2, then add value b to every element of the list.
if a=3, then we have to print the bth smallest element in the list.
e.g. query = 5, list = []
q1 -> 1 2 -> list = [2]
q2 -> 1 4 -> list = [2,4]
q3 -> 2 5 -> list = [7,9]
q4 -> 3 1 -> print(7)
I have tried a brute force approach, which takes O(N logN) for each query. How can I improve this for large queries? My brute force link