Goldman Sachs interview question

Trapping rainwater - Leet code hard question .