int findMin(vector<int>& arr)
{
int n = arr.size();
int low = 0;
int high = n-1;
int mini = INT_MAX;
while(low<=high){
int mid = (low+high)/2;
// if the whole array is sorted or if both the left and right half are sorted
// then we just take the arr[low]
if(arr[low]<=arr[high]){
mini=min(mini,arr[low]);
break;
}
// just check if the left half is sorted
// if it is then take arr[low] and eliminate left half
if(arr[low]<=arr[mid]){
mini=min(mini,arr[low]);
low=mid+1;
}
// checking for right half
// so this situation will come if left half is not sorted
// take the arr[mid] as it is sorted and elimate the right half as well
else{
mini=min(mini,arr[mid]);
high=mid-1;
}
}
return mini;
}