Amazon Interview Question

Rain water trapping question from leeycode