The Water Gauge
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant feedback.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
A terrain heightmap is stored as a list of non-negative bar heights. After heavy rain, water collects in the dips between taller bars; return the total units of water the profile traps.
Summary
Elevation bars trap water in the dips. Total the volume.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and checks it automatically.