Searching sorted data interview questions

Binary search on sorted lists, on rotated lists and grids, and on the answer itself, with the loop invariants that prevent off-by-one bugs.

5 quick facts

– interview-ready · 12 questions in this topic

– of 12 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. Where would a new price go in a sorted list?Predict
  2. Slowest reading pace that still finishes on timePredict
  3. Smallest value in a rotated sorted listPick the fix
  4. Find a value in a rotated sorted listPredict
  5. First and last position of a value in a sorted listFill the blank
  6. Whole-number square root without math.sqrtPredict
  7. Smallest truck that delivers every parcel in d daysPredict
  8. Highest point of a climb-then-descent routePick the fix
  1. Find a value in a grid sorted row after rowPredict
  2. Binary search without off-by-one bugsPredict
  3. Binary search on the answerPick the fix
  4. Using bisect and sorted lists in practicePredict

Practise this topic

Flashcards · 22

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 12 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Topic outline informed by the Tech Interview Handbook by Yangshun Tay and the NeetCode 150 pattern grouping by neetcode-gh, both MIT licensed. Every problem, solution and explanation is written by Best Latest Apps. Credits and license