Two-Column Layout: Best Divider Position

Asked at Waymo · Coding Questions · Difficulty: Medium · Last asked Nov 14, 2025

A table has two text columns that share a fixed total width `W`. A vertical divider sits at an integer position `w`: the left column gets width `w` and the right column gets width `W - w`. Each column places its words in order, greedily: a word goes on the current line if it fits (words on one line are separated by one unit of space), otherwise it starts a new line. A column's height is its number of lines, or 0 if it has no words. Choose the divider that makes the taller column as short as possible.

Loading the problem…