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):