Walmart interview question

Water trapping problem from leetcode -DSA