Problem of the day
You are given an array 'arr' of size 'n' having unique elements that has been sorted in ascending order and rotated between 1 and 'n' times which is unknown.
The rotation involves shifting every element to the right, with the last element moving to the first position. For example, if 'arr' = [1, 2, 3, 4] was rotated one time, it would become [4, 1, 2, 3].
Your task is to find the minimum number in this array.
All the elements in the array are distinct.
Input: arr = [3,4,5,1,2]
Output: 1
Explanation: The original array was [1,2,3,4,5] and it was rotated 3 times.
The first line contains an integer 'n', the size of the array.
The second line contains 'n' space-separated integers.
The only line contains the minimum number in the given array.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
4
3 4 1 2
1
The original array was [1, 2, 3, 4] and it was rotated 2 times.
6
25 30 5 10 15 20
5
The original array was [5, 10, 15, 20, 25, 30] and it was rotated 2 times.
Try to solve this with O(log(n)) time complexity.
1 <= n <= 10^5
1 <= arr[i] <= 10^9
Time Limit: 1 sec