Rain water between walls
hardProblem solving40 XP
heights are the heights of walls of width 1, side by side. After rain, how many units of water are trapped between them? Water above a wall rises to the lower of the tallest walls on its left and right.
Examples
- Input: heights = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]Output: 6
- Input: heights = [4, 2, 0, 3, 2, 5]Output: 9
Examples use JSON: true/false/null are True/False/None in Python.