FastPrepTrapping Rain Water
Problems/Trapping Rain Water

Trapping Rain Water

Rupeek logoRupeek● HardONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamples

Problem statement

Source note: This problem is backed by a real Rupeek onsite interview report. The report directly named Trapping Rain Water, but it did not include a function interface, examples, or constraints. The core task match is about 95%.

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[]) → int

Examples

Example 1

height = [0,1,0,2,1,0,1,3,2,1,2,1]return = 6

Example 2

height = [4,2,0,3,2,5]return = 9

Similar 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
See Rupeek hiring insights
Saved
class Solution {
    public int trap(int[] height) {
      // write your code here
    }
}
Checking account…