← 返回 amazon 的题目列表Trapping Rain Water
类型:online_judge
Given an array representing the height of walls, compute how much water can be trapped.
Description
Given height, a non-negative integer array representing the heights of walls at each unit width. 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
Constraints
n == height.length
0 <= n <= 3 * 104
0 <= height[i] <= 105
Note
You need to solve the problem in O(n) time complexity.
Example
Input
0 1 0 2 1 0 1 3 2 1 2 1