Reverse sub array
Basic Accuracy: 30.39% Submissions: 9880 Points: 1

Provided an array of N integers, you need to reverse a subarray of that array. The range of this subarray is given by L and R.

Input:
The first line of input contains an integer T denoting the number of test cases. T testcases follow. Each testcases contains three lines of input:
The first line is N, the size of the array.
The second line contains N integers denoting the elements of the array.
The third line contains L and R, denoting the starting and ending positions of the subarray.

Output:
For each testcase, print the modified array.

Constraints:
1 ≤ T ≤ 200
1 ≤ N ≤ 107
1 ≤ A[i] ≤ 1000
1 ≤ L ≤ R ≤ N

Example:
Input:
1
7
1 2 3 4 5 6 7
2 4

Output:
1 4 3 2 5 6 7

Explanation:
Testcase 1:
After reversing the elements in range 2 to 4 (2, 3, 4), modified array is 1, 4, 3, 2, 5, 6, 7.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.