Visa Inc. Interview Question

Rainwater retention problem from leetcode.