Trains the technique from
LeetCode 154Find Minimum in Rotated Sorted Array IIThis 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 chart recorder writes its calibration readings around the rim of a drum, one reading per slot, in non-decreasing order all the way round. Repeated readings are ordinary: a stretch of slots may all carry the same figure.
Before the drum was read off, it was turned by somewhere between 1 and n slots, n being the number of slots. The array drum holds the readings as they were then read off, starting from the slot at the index mark and going once round. So drum is the non-decreasing sequence cut at one point, with the tail moved in front of the head.
Return the lowest reading on the drum. Aim to do it without reading every slot: your work should scale with the logarithm of n when the drum holds few repeats.
Example 1
Read from slot 2 onwards the drum gives 12, 45, 45, 61, 78, 78, which is the non-decreasing round, so the lowest figure on it is 12.
Example 2
The readings rise from -9 through four slots reading 4, and -9 is the lowest of them.
Example 3
Every slot carries 206, so that figure is both the highest and the lowest on the drum.
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_reading(drum: list[int]) -> int:public int lowestReading(int[] drum)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.