
‘N’ = 4, ‘V’ = [4,3,1,2], ‘Q’ = 3, ‘query’ = [5, 12, 3].
Train visits the station in the following manner:
For the period [0, 3], the train will be at station 1. (0th, 1st, 2nd, and 3rd) for 4 minutes on station 1.
For the period [4, 6], the train will be at station 2.
For the period [7, 7], the train will be at station 3.
For the period [8, 9], the train will be at station 4.
For the period [10, 11], the train will be at station 4.
For the period [12, 12], the train will be at station 3.
First Query: In the 5th minute, the train will be at station number 2. Hence, 2 will be the answer.
Second query: In the 12th minute, the train will be at station number 3. Hence, 3 will be the answer.
Third Query: In the 3rd minute, the train will be at station number 1. Hence, 1 will be the answer.
The final output will be: [2, 3, 1]
The first line contains a single integer ‘T’ denoting the number of test cases, then the test case follows.
The first line of each test case contains an integer, denoting ‘N', length of ‘V’.
The second line contains ‘N’ single space-separated integers denoting ‘V’.
The third line contains an integer, denoting ‘Q’.
The fourth line contains ‘Q’ single space-separated integers denoting ‘query’.
For each test case, return an array that contains answers to all queries.
Output for each test case will be printed on a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 ≤ T ≤ 10
2 ≤ N ≤ 10^5
1 ≤ V[i] ≤ 10^3
1 ≤ Q ≤ 10^5
0 ≤ query[i] ≤ 10^9
It’s guaranteed that sum of N and Q over all test cases does not exceed 10^5.
Time limit: 1 sec
Algorithm:
Element Count in Ranges
First Digit One
Minimize Maximum Adjacent Distance
Sorted Doubly Linked List to Balanced BST
Minimized Maximum of Products Distributed to Any Store