capturing_rainwater() function that takes in an array of heights, and returns the amount of rainwater that could be contained in that array.
For example, the array
[4, 2, 1, 3, 0, 1, 2] can be represented in the following histogram:
As you can see, there are 6 units of water that can be contained, so
capturing_rainwater([4, 2, 1, 3, 0, 1, 2]) will return
This challenge was reported to have been asked at interviews with many top companies, including Amazon and Microsoft. If you’ve covered the material in Pass the Technical Interview with Python or an equivalent, you should be able to solve this challenge. If you have trouble, try refreshing your knowledge with its Capturing Rainwater walkthrough.