class Solution {
public:
int findMin(vector<int> &num) {
int n = num.size();
if( n == 1 ) {
return num[0];
}
int low = 0 , high = n-1;
while ( low<= high ) {
int mid = low + (high-low)/2;
if( mid != n-1 && num[mid] > num[mid+1] ) {
return num[mid + 1];
}
else if( mid != 0 && num[mid-1] > num[mid] ) {
return num[mid];
}
else if (num[low] < num[mid] ) {
low = mid + 1;
}
else {
high = mid - 1;
}
}
return num[0];
}
};
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
180+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →