← Questions

Trapping rain water

0
TeslaCodingLast asked Sep 2025

Given bar heights in an elevation map, each of width 1, compute how much water is trapped after rain. Start with the brute-force solution and its complexity, then improve it to O(n) time (prefix maxima), then to O(1) extra space with two pointers.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding