🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 13 - Searching AlgorithmsPractice QuestionsOverview

Searching Practice Questions

Eight interview classics. Every one is a direct application of the unified binary-search template — once you can spot the monotonic predicate, the code writes itself.

For each problem, before reading the solution, ask:

  • What’s the answer space? Array indices? Integers? Real numbers?
  • What’s the monotonic predicate? “Is arr[i] ≥ target?” “Can we ship in D days at capacity c?”
  • First true or last true? First → use the template directly. Last → flip the predicate.

Three questions, three lines of work, one template. That’s the whole chapter.

Easy

ProblemPatternStatus
Binary SearchCanonical templateAvailable
Search Insert PositionLower bound (template, no found-check)Available
First Bad VersionBoundary-finding via API callAvailable
Sqrt(x)Binary search on the answerAvailable

Medium

ProblemPatternStatus
Find First and Last Position of ElementLower bound + upper bound − 1Available
Find Peak ElementBinary search on the slopeAvailable
Find Min in Rotated Sorted ArrayCompare with arr[hi]Available
Search in Rotated Sorted ArrayDecide which half is sortedAvailable

More Practice (Coming Soon)

ProblemPatternStatus
Koko Eating BananasBinary search on speedComing Soon
Capacity to Ship Packages in D DaysBinary search on capacityComing Soon
Split Array Largest SumBinary search on max sumComing Soon
Find K Closest ElementsBinary search + two-pointerComing Soon
Median of Two Sorted ArraysTwo-array binary search partitionComing Soon
Search 2D MatrixTreat 2D as 1D, then binary searchComing Soon
Find K-th Smallest Pair DistanceBinary search on distanceComing Soon
Aggressive Cows / Place K markersBinary search on minimum gapComing Soon