Problem · Array
Trapping Rain Water
Learn this problemProblem statement
Given non-negative bar heights where every bar has width 1, return the total amount of rain water trapped between the bars.
Function
trap(height: int[]) → intExamples
Example 1
height = [0,1,0,2,1,0,1,3,2,1,2,1]return = 6Example 2
height = [4,2,0,3,2,5]return = 9