Binary Search on Answer: Advanced Problems
Solve advanced binary search on answer problems — Koko eating bananas, ship packages, split array largest sum, minimize max distance to gas station, and magnetic force between balls.
15 posts · page 1 of 1
Solve advanced binary search on answer problems — Koko eating bananas, ship packages, split array largest sum, minimize max distance to gas station, and magnetic force between balls.
Master longest subsequence problems — LIS with patience sorting, longest bitonic, chain of pairs, zigzag subsequence, Russian doll envelopes (2D LIS).
Master binary search with three templates -- exact match, first/last true, and answer space search. Covers rotated arrays, peak elements, and common off-by-one mistakes.
Learn to binary search on the answer space — the powerful technique behind problems like splitting arrays, Koko eating bananas, and capacity to ship packages.
Use git bisect to binary search through your commit history and pinpoint the exact commit that broke your code. Covers manual, automated, and advanced bisect workflows.
Master binary search patterns for LeetCode including search space reduction, boundary finding, rotated array search, and practical templates.
Solve Capacity to Ship Packages Within D Days by binary searching the ship capacity. Includes feasibility check, tight bounds, and a worked example.
Solve Find Peak Element in O(log n) by binary searching on the slope direction. Includes diagram and edge cases.
Solve First Bad Version with binary search and overflow-safe midpoint calculation. Includes API constraints and complexity.
Solve Koko Eating Bananas by binary searching the eating speed. Includes the monotonic predicate, ceiling division, and complexity.
Solve Search a 2D Matrix by treating the sorted matrix as a flat sorted array and binary searching. Includes index arithmetic and complexity.
Solve Find Minimum in Rotated Sorted Array in logarithmic time with a modified binary search. Learn the pivot-finding invariant, edge cases, and how to extend the pattern to related problems.
Longest Increasing Subsequence in detail — the O(n^2) DP, the O(n log n) patience-sorting trick with binary search, and when each one matters.
Solve Search in Rotated Sorted Array in O(log n) with modified binary search. Pivot detection, half-decision logic, and interview talking points.
A practical guide to binary search — the classic template, off-by-one traps, Python's bisect module, and the binary-search-on-answer pattern, with six worked problems.