Trains the technique from
LeetCode 81Search 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 weather station files temperatures into a ring of fixed size. It files them in non-decreasing order and carries on around the ring, so a reading may equal the one filed before it.
A download starts at whichever slot the reader happens to open at and then walks the ring all the way round. What comes out is log: the non-decreasing run of temperatures shifted round by some number of slots. The shift may be zero, in which case log is simply the run itself.
Return true when the temperature wanted sits in some slot of log, and false otherwise.
Example 1
The download opened three slots along, so the run 8, 9, 12 comes out first and -3, -1, 3 follows. The temperature -1 sits at index 4.
Example 2
The temperature -1 sits at index 1 of the download.
Example 3
No slot of the download holds 7.
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 reading_present(log: list[int], wanted: int) -> bool:public boolean readingPresent(int[] log, int wanted)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.