GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
← Coding & DSA / 80
mediumMetaAmazonMicrosoft

Search in a rotated sorted array

A sorted array got rotated at an unknown pivot and you still have to find a target in O(log n). The trick is deciding which half is sorted at every step. Here's the clean invariant, and the duplicates follow-up that quietly breaks the log-n promise.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

A sorted array got rotated at an unknown pivot and you still have to find a target in O(log n). The trick is deciding which half is sorted at every step. Here's the clean invariant, and the duplicates follow-up that quietly breaks the log-n promise.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 559 remaining answers · ₹2,000 / $25

Every answer, concept and course, every paper breakdown, all published video lessons, hands-on FDE Lab missions, Premium PDF guides and companion files, the full practice-test bank and work-sample downloads. Referral Premium excludes guide PDFs and their companion files.

6 months · One payment · No auto-renewal

Study alongside free video lessons.

Keep practising

FEDITOR'S NOTE

The real signal is whether you can state the loop invariant before coding: at every step one half is sorted, you check whether the target lies inside that sorted half, and you discard the other half. Candidates who pattern-match to 'plain binary search' without handling the pivot get a subtly wrong answer that passes the happy path and fails on the rotated case. The duplicates follow-up is the separator: it forces you to admit O(log n) is no longer guaranteed.

DISCUSSION · 0

No comments yet — be the first to share your approach.