Marks :15
: 6 | : 3
You are given an array $$$A$$$ consisting of $$$N$$$ continuous natural numbers denoting the seat numbers in a theater. The array values are as follows $$$A = [1, 2, 3, ..., N]$$$.
You have to process $$$Q$$$ queries of two different types:
The current seat number $$$X$$$ is occupied now (denoted by 0), and the seat number of all the vacant seats that have current seat numbers greater than $$$X$$$ is decreased by one.
Thus, the enumeration of seats (i.e. current seat numbers at the theater) always remains continuous.
Determine the original seat number (seat number before processing any query) of the current seat number $$$X$$$.
Determine the original seat number for each type 2 query in the given order.
The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.
The first line of each testcase contains two space separated integers $$$N$$$ and $$$Q$$$ $$$(1 \le N, Q \le 10^5)$$$ — the number of elements in array $$$A$$$ and the number of queries respectively.
The next $$$Q$$$ lines of each testcase contains two space separated integers $$$type$$$ $$$(1 \le type \le 2)$$$ and $$$X$$$ $$$(1 \le X \le N)$$$ denoting the $$$type$$$ and the value of $$$X$$$ for this query respectively.
It is guaranteed that the sum of $$$N$$$ and $$$Q$$$ over all testcases does not exceed 1e5 respectively and that there are atleast $$$X$$$ elements in $$$A$$$ for each query.
For each testcase, print the answer to each query of type $$$2$$$ in a single line.
2 6 5 2 3 1 3 2 3 1 2 2 4 5 5 1 2 1 1 2 1 1 2 2 2
3 4 6 3 5
For sample test case 1,
Initially, $$$A = [1, 2, 3, 4, 5, 6]$$$ (all seats are vacant)
Therefore, the answer is $$$[3, 4, 6].$$$
For sample test case 2,
Initially, $$$A = [1, 2, 3, 4, 5]$$$ (all seats are vacant)
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.