AO
AceOffer
·
Back

Binary Search Optimization Problem

CodingPhone, OnsiteSoftware Engineer, Machine Learning EngineerLast reported April 2026Low Frequency

Problem Overview

Given a two-column table where: the text content of both columns is known, the total table width is fixed, and the column divider can be placed at any position — find the optimal placement of the column divider that minimizes the total height (length) of the table.
Full problem statement
Given a two-column table where: the text content of both columns is known, the total table width is fixed, and the column divider can be placed at any position — find the optimal placement of the column divider that minimizes the total height (length) of the table. The table height is determined by the taller of the two columns after text wrapping. Handle corner cases such as a single word whose length exceeds the available cell width.

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Trade-off discussion · 3
Trade-off discussion
What if a single word is longer than the cell width assigned to its column?
Probes for: Candidate solves the base case
If multiple divider positions give the same minimum table height, how do you handle that?
Probes for: Candidate finds the optimal position
How do you prove/justify the monotonicity or unimodal property needed for binary search to work here?
Probes for: Candidate proposes binary search

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Linear scanTry every possible divider position and compute table height for each; O(W * (N1 + N2)) where W is total width and N1, N2 are text lengths. Simple to implement but slower than binary/ternary search.
Ternary searchWorks cleanly on unimodal functions; slightly more intuitive than binary search when the monotonicity argument is not immediately obvious, but requires verifying the unimodal property.

Practice

Open the editor to write a solution against test cases, then return here to compare against the follow-ups.
Open Editor →
Waymo · Coding · Reported 2× across candidate reports