NumPy allowed · plain Python earns 10 bonus points
Implement Trapping Rain Water via precomputed left-max/right-max arrays -- the classic hard array problem, and the key insight (water trapped at any position depends only on the shorter of the tallest walls to its left and right) that makes an O(n)-time, O(n)-space solution possible.
Implement trap_rain_water(height): precompute, for every position, the tallest bar to its left (inclusive) and the tallest bar to its right (inclusive). The water trapped at that position is max(0, min(left_max, right_max) - height[i]); sum this over every position.
trap_rain_water(height: list[int]) -> int