> For the complete documentation index, see [llms.txt](https://mayanktyagi3111.gitbook.io/interview-prep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mayanktyagi3111.gitbook.io/interview-prep/binary-searching-and-sorting/rotated-array.md).

# Rotated Array

Suppose a sorted array A is rotated at some pivot unknown to you beforehand.

*(i.e., `0 1 2 4 5 6 7` might become `4 5 6 7 0 1 2`)*.

Find the minimum element.

The array will not contain duplicates.

```java
public class Solution {
    public int findMin(final List<Integer> a) {
        int start = 0;
        int end = a.size() - 1;
        while (start < end) {
            int mid = (start + end) / 2;
            if (a.get(start) < a.get(end))
                return a.get(start);
            if (a.get(mid) >= a.get(start))
                start = mid + 1;
            else
                end = mid;
        }
        return a.get(start);
    }
}
```
