Hard
Trapping Rain Water
Topic: Dynamic Programming •
Acceptance: 38%
Given `n` non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Input Format:
First line: n. Second line: n elevation heights.
Output Format:
Print the total trapped water volume.
Sample Example:
Sample Input:
12 0 1 0 2 1 0 1 3 2 1 2 1Sample Output:
6
Sandboxed Engine
Ready to test. Click Test All Cases or Submit Solution to evaluate your code.
// Code Playground Cloud Execution Engine v2.4
// Write your code and click 'Run Code' to execute.
$ ready
Standard Input (stdin):
Your code can read standard input via
stdin.