Here is the interview question prompt, presented for reference.
Suppose you are given an elevation map composed of bars of different heights. You can assume that each bar has the same width. Can you figure out how much rain it will collect?
There can be different ways of representing an elevation map. We'll consider the simplest method of using a one dimensional array of non-negative numbers to represent the height at different places. The goal is to find out how much rain can be trapped when given an elevation map. The figure below shows various elevation maps and the units of rain water they can catch.
O(n)time complexity and
You can see the full challenge with visuals at this link.
Challenges • Asked about 3 years ago by Jake from AlgoDaily
This is the main discussion thread generated for Trapping Rain Water.
There are no test cases and the environment does not support python
Thanks for the heads up and sorry for the miss! Added to the queue for the team to address, will update when resolved.
Updated and resolved :-)