Trapping Rain Water Problem
📖 Scenario: Imagine a street with buildings of different heights. When it rains, water gets trapped between these buildings. We want to find out how much water is trapped after the rain stops.
🎯 Goal: Build a program that calculates the total amount of water trapped between buildings represented by their heights.
📋 What You'll Learn
Create a list called
heights with exact building heightsCreate two lists called
left_max and right_max to store maximum heights from left and rightUse a loop to fill
left_max and right_maxCalculate trapped water using the minimum of
left_max and right_max for each buildingPrint the total trapped water
💡 Why This Matters
🌍 Real World
This problem models how water collects in valleys between buildings or hills, useful in urban planning and flood prediction.
💼 Career
Understanding this problem helps in software roles involving algorithms, problem solving, and optimization.
Progress0 / 4 steps