LeetCode 42 - Trapping Rain Water
Difficulty: hard
Problem Description
English (Trapping Rain Water)
Given n
non-negative integers representing an elevation map where the width of each bar is 1
, compute how much water it can trap after raining.
Example 1:
1 |
|
Example 2:
1 |
|
Constraints:
n == height.length
1 <= n <= 2 * 10^4
0 <= height[i] <= 10^5
Chinese (接雨水)
给定 n
个非负整数表示每个宽度为 1
的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。
示例 1:
1 |
|
示例 2:
1 |
|
提示:
n == height.length
1 <= n <= 2 * 10^4
0 <= height[i] <= 10^5
Solution
C++
1 |
|
Python
1 |
|
LeetCode 42 - Trapping Rain Water
http://wasprime.github.io/Algorithm/LeetCode/LeetCode-42-Trapping-Rain-Water/