Trapping Rain Water
HardGiven an array height where height[i] represents the elevation at index i, compute how much water can be trapped after raining.
Example:
Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The trapped water is illustrated by the elevation map, totaling 6 units of water.
Test Cases
Test Cases
Input
3 2 1 2 2 3 2
Expected Output
5
Step 1
Step 2
Step 3
Step 1: Identify the Pattern
Trapping Rain Water
HardGiven an array height where height[i] represents the elevation at index i, compute how much water can be trapped after raining.
Example:
Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The trapped water is illustrated by the elevation map, totaling 6 units of water.
Test Cases
Test Cases
Input
3 2 1 2 2 3 2
Expected Output
5
Step 1
Step 2
Step 3
Step 1: Identify the Pattern
Study Notes
Start Taking Notes!
Create and organize your study notes for this problem. Keep track of your solutions and insights.