Amazon interview question

Leetcode Hard: Trapping rain water 2