← 返回 amazon 的题目列表Trapping Rain Water
类型:online_judge
Problem: Trapping Rain Water
Given a non-negative integer array height where height[i] represents the height of the i-th bar and each bar has width 1.
Compute how much total rain water can be trapped after raining.
Input
Line 1: integer n, the length of the array
Line 2: n non-negative integers: height
Output
A single integer: the total trapped water.
Constraints
1 <= n <= 2 * 10^5
0 <= height[i] <= 10^9
Sample Tests (5)
(See the Chinese version for 5 concrete cases; same cases apply.)
Example
Input
12
0 1 0 2 1 0 1 3 2 1 2 1
Output
6