Binary Search on Answer
Learn Binary Search on Answer (Searching, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Binary Searching Over the ANSWER, Not the Array A powerful pattern: instead of searching for a value INSIDE an array, binary search over the RANGE OF POSSIBLE ANSWERS to a question, using a "can this candidate answer work?" check function. It applies whenever the answer space is MONOTONIC - if candidate X works, every candidate ≥ X also works (or vice versa).