#K66832. Partial Subarray Sorting
Partial Subarray Sorting
Partial Subarray Sorting
Given an array of integers and two indices l and r (using 1-based indexing), your task is to sort the subarray from index l to r (both inclusive) while leaving the rest of the array unchanged. The indices provided satisfy \(1 \leq l \leq r \leq n\), where \(n\) is the size of the array.
For example, if the array is \([3, 1, 4, 1, 5]\) and \(l = 2\) and \(r = 4\), the subarray \([1, 4, 1]\) will be sorted to become \([1, 1, 4]\), resulting in the array \([3, 1, 1, 4, 5]\).
This is a straightforward problem that tests your ability to manipulate subarrays and use basic sorting techniques.
inputFormat
The first line contains an integer \(n\) representing the number of elements in the array.
The second line contains \(n\) space-separated integers representing the elements of the array.
The third line contains two space-separated integers \(l\) and \(r\), which denotes the 1-based start and end indices for the subarray that needs to be sorted.
outputFormat
Output the modified array after sorting the specified subarray. The elements should be printed in a single line separated by a single space.
## sample5
3 1 4 1 5
2 4
3 1 1 4 5