Hard · Stacks & Queues
Trapping Rain Water (Stacks & queues)
Given an array height of non-negative integers, where each bar has width 1, return the total units of rain water trapped between the bars.
Examples
Example 1
[4,2,0,3,2,5] → 9Output: 9 units
Example 2
[3,0,2,0,4] → 7Output: 7 units
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.