~/boss / rotated-doors

Binary search in a rotated sorted array

The Twisted Doors

Someone rotated the sorted doors. Find door 42 in log n steps.

Loading the fight…

How to beat it

Split the range at the middle door: one half is always sorted. If the left end is no bigger than the middle, it's the left half. Is 42 inside that half's range? Keep it. If not, keep the other half.

Now the real boss

Interviews ask for the code. Watch it run, then write it yourself, tested in Python, C++ or Java.

On your phone? Writing code is easier on a laptop: open bossfight.dev/problems/search-in-rotated-sorted-array there. Sign in with your email to keep your progress on every device.

More bosses

esc