#K86222. Find Minimum in Rotated Sorted Array
Find Minimum in Rotated Sorted Array
Find Minimum in Rotated Sorted Array
You are given a rotated sorted array which was originally sorted in increasing order and then rotated at an unknown pivot. Your task is to find the minimum element in the array.
The rotated sorted array follows the property that:
\( A = [a_0, a_1, \ldots, a_{n-1}] \) is sorted in increasing order and has been rotated, meaning there exists an index \( k \) (where \( 0 \leq k < n \)) such that:
\( A = [a_k, a_{k+1}, \ldots, a_{n-1}, a_0, a_1, \ldots, a_{k-1}] \).
If the array is empty, output None
.
inputFormat
The input is given via stdin and consists of two lines:
- The first line contains an integer \( n \), the number of elements in the array.
- The second line contains \( n \) space-separated integers representing the elements of the rotated sorted array. If \( n = 0 \), the second line will be empty.
outputFormat
Output via stdout a single line containing the minimum element in the array. If the input array is empty, output None
.
7
4 5 6 7 0 1 2
0
</p>