Given non-negative integers representing an elevation map where the width of each bar is , compute how much water it can trap after raining.
Example: heights Answer: This you can solve with stacks, but also with two pointers or dynamic programming. The stack approach uses the histogram insight: calculate trapped water layer by layer.