Goldman Sachs Interview Question

Trapping rainwater. Leetcode hard question