BackhardRecursion

Elevation Water Accumulation Solution

Problem Statement

Given an array of non-negative integers representing elevation bars, calculate the total amount of water that can be trapped between these bars.

Example 1
Input
[0,1,0,2,1,0,1,3,2,1,2,1]
Output
6

Explanation: Water can be trapped between the bars

Constraints

  • 1 <= elevationArray.length <= 1000
  • 0 <= elevationArray[i] <= 1000
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free