Problem. height[i] is the height of a vertical wall at position i. Choose two walls i < j; together with the
x-axis they hold water with area (j − i) × min(height[i], height[j]). Return the maximum area.
height = [1, 8, 6, 2, 5, 4, 8, 3, 7] → 49 (walls at 1 and 8: width 7 × height 7)
height = [1, 1] → 1
ML context. The useful part isn't water: it's the proof technique. When an objective is limited by the smaller of two parts (a bottleneck), you can discard the limiting part once you've scored it, because no other choice can help it. The same "bound, then prune" reasoning powers early stopping in hyperparameter search and pruning in nearest-neighbour search: skip whatever provably can't beat the best answer so far.