← 返回 meta 的题目列表Trapping Rain Water (Two Pointers)
类型:online_judge
Given a non-negative integer array height where each bar has width 1, compute how much water can be trapped after raining.
Input:
First line: integer n
Second line: n non-negative integers height[i]
Output: one integer, the total trapped water
Example
Input:
12
0 1 0 2 1 0 1 3 2 1 2 1
Output:
6
Constraints
1 <= n <= 2e5
0 <= height[i] <= 1e9
Example
Input
12
0 1 0 2 1 0 1 3 2 1 2 1
Output
6