FastPrepTrapping Rain Water
Problems/Trapping Rain Water

Trapping Rain Water

Citadel logoCitadel● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel phone screen. The report names a well-known problem without copying its statement. This version uses the standard model of bars one unit wide, with heights that are not negative. An empty array holds zero water.

Our version is about 98% the same as the reported question.

Each nonnegative integer in height is the height of a unit-width bar. Return the total water trapped between the bars after rain.

Water above a bar is limited by the shorter of the tallest bars on its left and right, including that bar itself.

Function

trap(height: int[]) → int

Examples

Example 1

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

The trapped depths at indices 2, 4, 5, 6, 9, and 10 are 1, 1, 2, 1, 1, and 0. Their sum is 6.

Example 2

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

The interior depths are 2, 4, 1, and 2, for a total of 9.

Constraints

  • 0 <= height.length <= 20000
  • 0 <= height[i] <= 100000

More Citadel Phone Screen questions

  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
  • Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
  • Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
  • Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026
  • Top Ten Trades by Notional ValuePHONE SCREEN · Seen Sep 2026
  • Exchange BBO and Market-Wide NBBOPHONE SCREEN · Seen Sep 2026
  • Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Subarray Product Less Than KApple · PHONE SCREENApple interview questions
  • 3SumAmazon · PHONE SCREEN
  • Subarray Product Less Than KAngel One · PHONE SCREEN
  • Subarray Product Less Than KThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Trapping Rain WaterGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Candy Crush Grid Matching and GravityRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
  • Meeting Rooms IIUber · PHONE SCREENUber interview questions
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions

Interview reports that mention this question

  • Citadel SWE Intern First-Round Questions: 20 Experiences

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public int trap(int[] height) {
        // write your code here
    }
}
Checking account…