Trains the technique from
LeetCode 153Find Minimum in Rotated Sorted ArrayThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A weather buoy stores calibration offsets in a ring buffer. The offsets were written into the ring in strictly increasing order, one per slot, and afterwards the buffer's start marker was slid forward by some number of slots. Dumping the ring from the marker therefore hands you the increasing run cut at one slot, with the piece before the cut moved behind the piece after it. The marker may also have been slid all the way around the ring, and then the dump comes out plainly increasing.
Offsets can be below freezing, so negative values are ordinary. No two offsets are equal.
Given the dump offsets, report the smallest offset it holds. Your routine must settle the answer in logarithmic time, so reading every slot is off the table.
Example 1
The increasing run was -9, -7, -4, -1, 3; the cut fell after -1, so the run restarts at slot 3 and the low offset sits there.
Example 2
The marker travelled the full ring, so the dump is still increasing and the low offset is the first slot.
Example 3
Two slots with the cut between them, so the second slot restarts the run.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def lowest_offset(offsets: list[int]) -> int:public int lowestOffset(int[] offsets)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.