Your question is Water Container Coding. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Komodo Health's Mosaic platform can represent changing measurements as a sequence of nonnegative heights. Given a cross-section of vertical bars, calculate how much water remains trapped after rainfall between those bars.
Each bar has width 1. Water can be trapped above a bar only when there is a taller boundary on both its left and right. Return the total trapped volume.
Implement trap_rainwater(height), which accepts a list of nonnegative integers and returns an integer representing the total trapped water. The result must be computed without modifying the input list.
def trap_rainwater(height):