← All problems

Trapping Rain Water

Hard arraystwo-pointersstacks LeetCode ↗
Given an elevation map, compute how much water it traps after raining.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(1)

Common pitfalls

  • Adding negative water (clamp at 0)
  • Wrong pointer-move condition

Your solution

Log in to save your code and track progress.