Problem Description
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
For example,
Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.
problem link:
https://leetcode.com/problems/trapping-rain-water
Solution
1 | public class TrappingRainWater_42 { |
算法解释
对任意位置 i,在 i 上的积水,由左右两边最高的 bar 决定。