Trapped Rainwater
ARRAY
STACK
DYNAMIC PROGRAMMING
Problem
Given an array height
representing the height of towers (each having width 1), compute how much water it can trap after raining.
Examples
trapRainWater([2,0,2,1,0,1,3]) // returns 6
Loading...
Loading...Loading...