All challenges

Algorithm challenge · DSA

Trapping Rain Water

Difficulty

hard

Time

~40m

Format

Single

Grading

Auto-graded

#python#javascript#typescript#go#java#cpp#rust#dsa#two-pointers#stack
Mission file // read carefullyhard

Given height, an array of non-negative integers representing an elevation map where the width of each bar is 1, return how much water it can trap after raining.

Example

height = [0,1,0,2,1,0,1,3,2,1,2,1]  =>  6

Build with

trap(height: int[]) → int
PythonJavaScriptTypeScriptGoJavaC++Rust
5 tests · 2 hidden
Auto-graded on submit
Start challenge

Sign in to save your progress.