Walmart Interview Question

Water trapping problem from leetcode -DSA