Leetcode 154: Find Minimum in Rotated Sorted Array II

Draw out various use cases. We can see that if left < right then left is the minimum. Do a binary search. If r < m then search right half. Otherwise if m < l search left half. The one complication is duplicate values. If we have a situation where l == m == r then we need to step forward l and step back r until l,m,r are not the same.

This entry was posted in programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.