Cisco interview question

Trapping water leetcode hard problem