0042. Trapping Rain Water
https://leetcode.com/problems/trapping-rain-water
Description
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:

Example 2:
Constraints:
n == height.length1 <= n <= 2 * 1040 <= height[i] <= 105
ac1: two pointers
ac2: brute force
ac3: DP-like memorization
ac4: stack
Very hard to understand, doubt if it's suitable for interview. https://leetcode.com/problems/trapping-rain-water/discuss/17414/A-stack-based-solution-for-reference-inspired-by-Histogram
Last updated
Was this helpful?