#K3801. Find Minimum in a Rotated Sorted Array

    ID: 26103 Type: Default 1000ms 256MiB

Find Minimum in a Rotated Sorted Array

Find Minimum in a Rotated Sorted Array

You are given a rotated sorted array of unique integers. A rotated sorted array is obtained by taking a sorted array and rotating it at some unknown pivot. Your task is to find the minimum element in this array using an efficient algorithm with a time complexity of \(O(\log n)\). The binary search approach is recommended.

Recall that the mid-point in binary search is calculated as: \( mid = \lfloor (left + right) / 2 \rfloor \).

inputFormat

The input consists of two lines:

  • 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 rotated sorted array.

outputFormat

Output a single integer which is the minimum element in the array.

## sample
5
3 4 5 1 2
1