def place_divider(left_text, right_text, total_width):
One Waymo phone-screen report (November 2025) gives this problem. The candidate solved it with binary search and names one corner case; a reply on the thread works through an example.
Part 1 — Place the column divider
A table has two columns. You know the text in each column and the table's total width, and the divider between the columns can go anywhere. Place it so the table is as short as possible.
Our setup for wrapping: each line of a cell holds as many words as fit, with one space between words, and a cell is as tall as the number of lines its text needs. The table is as tall as its taller column. The reported corner case is a word longer than its cell. On this page such a word does not fit, so that placement is not allowed (the clarifications cover the other reading).
Our setup: widths are counted in characters, the divider takes no width, and the two column widths add up to total_width, each at least 1.
column_height(text: str, width: int) -> int returns the number of lines text takes in a cell width characters wide. The tests call it only when every word fits.place_divider(left_text: str, right_text: str, total_width: int) -> tuple[int, int] returns (left_width, height): a left-column width that makes the table shortest, and that height. When several placements tie, any of them is accepted.From one Waymo phone-screen report (November 2025), posted with no outcome. The candidate solved it with binary search and mentions corner cases such as a word longer than its cell. The thread then works through an example: a 120-letter paragraph beside a 60-letter one, where a divider in the middle leaves the left column taller and setting the height, so the divider should move right. A reply asks what happens when several placements tie, or when the divider itself takes a space, and suggests any shortest placement should do.
One Waymo phone-screen report (November 2025) gives this problem. The candidate solved it with binary search and names one corner case; a reply on the thread works through an example.
Part 1 — Place the column divider
A table has two columns. You know the text in each column and the table's total width, and the divider between the columns can go anywhere. Place it so the table is as short as possible.
Our setup for wrapping: each line of a cell holds as many words as fit, with one space between words, and a cell is as tall as the number of lines its text needs. The table is as tall as its taller column. The reported corner case is a word longer than its cell. On this page such a word does not fit, so that placement is not allowed (the clarifications cover the other reading).
Our setup: widths are counted in characters, the divider takes no width, and the two column widths add up to total_width, each at least 1.
column_height(text: str, width: int) -> int returns the number of lines text takes in a cell width characters wide. The tests call it only when every word fits.place_divider(left_text: str, right_text: str, total_width: int) -> tuple[int, int] returns (left_width, height): a left-column width that makes the table shortest, and that height. When several placements tie, any of them is accepted.| Approach | Notes |
|---|---|
| Linear scan | Try every divider position and wrap both texts each time: O(n W) for n characters and total width W. Simple and correct; binary search cuts it to O(n log W). |
| Ternary search | Possible, but the height has flat stretches, so ternary search needs careful plateau handling. The crossover binary search is simpler to get right. |
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.