Reverse sub array
Submissions: 7404   Accuracy:

30.32%

  Difficulty: Basic   Marks: 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.

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.