Trapping Rain Water
Updated
Problem 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 = 9Similar questions at other companies
- Trapping Rain WaterBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Trapping Rain WaterAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Trapping Rain WaterKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Trapping Rain WaterNuro · ONSITE INTERVIEWNuro interview questions
- Trapping Rain WaterMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Trapping Rain WaterGoogle · OAGoogle interview questions
- Rain Kept Between WallsDocuSign · PHONE SCREENDocuSign interview questions
- Rain Water Held Between BarsAdobe · PHONE SCREENAdobe interview questions
- Construct a Tree from Level-Order and Inorder TraversalsSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Largest Rectangle in HistogramTekion · ONSITE INTERVIEWTekion interview questions