At Uber, each driver maintains a queue of ride requests.
Requests arrive one by one. Each request must be inserted at a specified position in the queue.
Rules:
When inserting at position index[i], all existing elements at that position and beyond shift one step to the right.
Insertions happen in order from i = 0 to n-1.
The queue grows dynamically.
Return the final sequence after all insertions.
Function Signature
vector<int> scheduleRequests( vector<int> index, vector<int> request );
Example
N=3 Index =[0,1,1]
Request =[0,1,2]
Output 0 2 1
The output array goes through the following steps: []→[0]→[0,1]→[0,2,1].
1 ≤ n ≤ 2 × 10^5
0 ≤ index[i], request[i] < n
0 ≤ i < n