Deviopath › JavaScript

Trapping Rain Water

Hard · Arrays

The array heights describes walls of width 1 standing next to each other. After it rains, water collects in the dips between walls.

Write a function trapWater that returns how many units of water are trapped in total.

Next: Minimum Window Substring