/rain-water-trap

frontspot battle task

Primary LanguageJavaScript

Rain Water Trap

Desctiption

Given n non-negative integers representing an elevation map where the width of each bar is 1. Write a function to measure how much water it is able to trap this elevation map after raining.

For example:

  Given elevation map: [0,1,0,2,1,0,1,3,2,1,2,1].
  Rain...
 
  const elevationMap = [0,1,0,2,1,0,1,3,2,1,2,1];

  trapRainWater(elevationMap); //6

After rain

Write your code in src/index.js

Run test locally npm test