Problem of the day
You need to reverse the string in O(N) time complexity.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain an integer ‘N’ where ‘N’ is the size of the queue.
The last line of each test case will contain the ‘N’ elements of the queue.
For each test case, print the elements of the reversed queue.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of. You just need to complete the function.
1 <= T <= 50
1 <= N <= 10^4
0 <= Q[i] <= 10^5
Where Q[i] denotes the value ith element of the input queue.
Time Limit: 1 sec
2
3
2 3 1
5
6 8 9 2 3
1 3 2
3 2 9 8 6
In the first test case, after reversing the queue, the resultant elements of the reversed queue will be 1 3 2.
In the second test case, after reversing the queue, the resultant elements of the reversed queue will be 3 2 9 8 6.
2
7
6 8 9 11 15 2 3
4
1 2 3 4
3 2 15 11 9 8 6
4 3 2 1
In the first test case, after reversing the queue, the resultant elements of the reversed queue will be 3 2 15 11 9 8 6.
In the second test case, after reversing the queue, the resultant elements of the reversed queue will be 4 3 2 1.