Search
⌘K

Leetcode 3061. Calculate Trapping Rain Water

Given an array of non-negative heights representing elevation bars, compute the total amount of water that can be trapped after rainfall. The core challenge is, for each index, to determine the limiting left/right maxima and sum max(0, min(left_max, right_max) − height) efficiently (optimal solutions run in O(n) time with constant or linear extra space).

Asked at:

Goldman Sachs

Apple


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid January, 2026

Goldman Sachs

Junior

Mid September, 2024

Apple

Senior

Trapping rain water

Your account is free and you can post anonymously if you choose.