arrow_back Back to Challenges

#42 Trapping Rain Water

Hard Acceptance 0%
description

Problem 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.

checklist Constraints

n == height.length
1 <= n <= 2 * 10^4
0 <= height[i] <= 10^5

science Examples

Case #1

In: height = [0,1,0,2,1,0,1,3,2,1,2,1]
Out: 6

Case #2

In: height = [4,2,0,3,2,5]
Out: 9

Mastery Tags

Arrays Dynamic Programming Stack Two Pointers

Hiring Companies

Amazon Goldman Sachs Google
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude