Drop the shorter wall
transcript
A row of barriers can hold rain between two of them. Which two make the largest tank? Start at both ends.
The tank is as high as the shorter wall. It is as wide as the gap between them. Its size is height times width.
Give up the taller wall and the code returns eight. Give up the shorter wall instead. The best tank, forty-nine, is found.
Moving a pointer in shrinks the gap. The shorter wall limits every tank it joins. So keeping it can never give a larger tank.
Each step moves one pointer inward. A pointer never goes back. So the walk takes at most n steps.
The rain problem uses the same idea. Move the pointer at the lower tower. That side's water level is already known. It depends only on the tallest tower on that side.
Name the end you drop. Say why it is safe. The pointers meet in n steps. Full breakdown in the lecture.