Squarepoint Capital interview question

Leetcode Question 47, filling the rain water.