Submit solution
Points:
4
Time limit:
1.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
C, C++, Java, Python
Reversing Subarrays
You are given an array, which you will need to reverse times at a given starting index, and an ending index, both inclusive.
Input Specification
The first line of input is the size of the array .
In the next line, there are space-separated integers that represent the values in the array, where .
The next line has the integer which is how many times the array is to be reversed.
The next lines each have 2 space-separated integers representing the starting index and the ending index, respectively.
Output Specification
Print out the array with each element separated by a space after each reversal.
Sample Input
10
1 2 3 4 5 6 7 8 9 10
2
0 9
3 8
Sample Output
10 9 8 7 6 5 4 3 2 1
10 9 8 2 3 4 5 6 7 1
Comments