Problem. A sorted array of distinct integers was rotated between 1 and n times: [0, 1, 2, 4, 5, 6, 7] may
become [4, 5, 6, 7, 0, 1, 2], or stay as it was after n rotations. Return the minimum, in O(log n).
[3, 4, 5, 1, 2] → 1
[4, 5, 6, 7, 0, 1, 2] → 0
[11, 13, 15, 17] → 11 (rotated n times: sorted again)
ML context. The minimum of a rotated sorted array is the oldest entry of a ring buffer. A metrics agent or a replay buffer writes samples in time order into a fixed array and wraps around. After a restart, the write head is often lost, but the timestamps are still there: finding the oldest one tells you where the buffer starts, and then every other lookup is an ordinary binary search (lesson 5.5, Change C).