#C9284. Minimum First Position After Reversal Operation
Minimum First Position After Reversal Operation
Minimum First Position After Reversal Operation
You are given an array of n integers. You are allowed to perform at most one reversal operation on a contiguous subarray. Your task is to determine the minimum possible value that can appear at the first position of the array after performing at most one reversal.
Observation: Reversing any subarray does not allow a value other than the global minimum to be brought to the first position. Hence, the answer is simply the minimum element of the array.
The array may contain duplicate values, and all values fit within the typical integer range.
inputFormat
The first line contains an integer n
representing the number of elements in the array.
The second line contains n
integers separated by spaces.
outputFormat
Output a single integer which is the minimum possible value that can appear at the first position of the array after performing at most one reversal operation.
## sample5
3 1 5 2 4
1