Problem. A sorted array of distinct integers was rotated at an unknown pivot: [0, 1, 2, 4, 5, 6, 7] might
become [4, 5, 6, 7, 0, 1, 2]. Given the rotated nums and a target, return its index or −1, in O(log n).
nums = [4, 5, 6, 7, 0, 1, 2], target = 0 → 4
nums = [4, 5, 6, 7, 0, 1, 2], target = 3 → -1
nums = [1], target = 0 → -1
ML context. Rotated sorted data appears whenever a ring buffer wraps around: a fixed-size buffer of the last N metric samples, a replay buffer in reinforcement learning, a circular log on an edge device. Data is written in time order, but the oldest entry sits wherever the write head currently is. Finding "the sample at time t" means searching a rotated sorted array.