FastPrepPour Water
Problems/Pour Water

Pour Water

Airbnb logoAirbnb● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Airbnb intern technical phone interviews in 2018 and 2019. The task was to pour some water onto a row of ground heights at one spot and find where the water ends up. Some interviewers also asked for a printed picture of the ground and the water.

The reports do not say which way water flows first or what happens at the ends of the row. Here, water tries the left side first, then the right side, then stays put, and both ends have tall walls. You return the final levels instead of printing a picture.

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

You are given an elevation map as an integer array heights. Index i is one unit wide, and heights[i] is the height of the ground there. Then volume units of water fall at index k, one unit at a time.

The level at an index is its ground height plus the water already resting there. Each unit of water starts on top of index k and moves by these rules:

  1. If the unit would eventually fall by moving left, it moves left.
  2. Otherwise, if the unit would eventually fall by moving right, it moves right.
  3. Otherwise, it stays at index k.

A unit can move across neighbors with the same level or a lower level, but never onto a higher level. To eventually fall in a direction means that walking that way reaches a level lower than the level at k. When it moves, the unit stops at the lowest level it can reach in that direction. If several reachable positions share that lowest level, it stops at the one closest to k. The unit then adds 1 to the level at that index.

Both ends of the array have walls that are higher than any level, so water never leaves the array.

Return the final level at every index after all volume units have settled.

Function

pourWater(heights: int[], volume: int, k: int) → int[]

Examples

Example 1

heights = [3,1,3,2,4]volume = 2k = 2return = [3,3,3,2,4]

The first unit starts on index 2 at level 3. Index 1 to the left has level 1, so the unit falls left. Index 0 has level 3, which is higher, so the unit stops at index 1. The levels become [3,2,3,2,4].

The second unit does the same thing. Index 1 rises from 2 to 3, so the final levels are [3,3,3,2,4].

Example 2

heights = [3,1,3,2,4]volume = 2k = 4return = [3,2,3,3,4]

Water falls at index 4, which has level 4. The first unit moves left to index 3 at level 2. The next index to the left has level 3, which is higher, so the unit stops at index 3. The levels become [3,1,3,3,4].

The second unit moves left to index 3 at level 3, crosses index 2 at the same level 3, and reaches index 1 at level 1. Index 0 has level 3, so the unit stops at index 1. The final levels are [3,2,3,3,4].

Example 3

heights = [5,4,4,4,5]volume = 3k = 2return = [5,5,5,5,5]

The first unit starts on index 2 at level 4. Its neighbors on both sides also have level 4, and the next ones have level 5. It cannot reach a lower level in either direction, so it stays. The levels become [5,4,5,4,5].

The second unit is now at level 5. Index 1 to the left has level 4, so it falls left and stops there. The levels become [5,5,5,4,5].

The third unit cannot reach a lower level on the left, because index 1 and index 0 both have level 5. On the right, index 3 has level 4, so it falls right. The final levels are [5,5,5,5,5].

Constraints

  • 1 <= heights.length <= 100
  • 0 <= heights[i] <= 99
  • 0 <= volume <= 2000
  • 0 <= k < heights.length

More Airbnb Phone Screen questions

  • Read Across Sound TracksPHONE SCREEN · Seen Nov 2026
  • Text JustificationPHONE SCREEN · Seen Nov 2026
  • Decode and Store StringsPHONE SCREEN · Seen Oct 2026
  • Print Sentences as TablePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Detonate Bombs with Chain ReactionsPHONE SCREEN · Seen Aug 2026
  • Smallest Common RegionPHONE SCREEN · Seen Aug 2026
  • Longest Chain BookingPHONE SCREEN · Seen Aug 2026
  • Nested List Iterator with RemovePHONE SCREEN · Seen Jul 2026
  • Parse Query StringPHONE SCREEN · Seen May 2026
  • Pacific Atlantic Water FlowPHONE SCREEN · Seen May 2023

Similar questions at other companies

  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Determine the Winner of Three-Card HandsOpenAI · PHONE SCREENOpenAI interview questions
  • Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Asteroid CollisionSiemens · PHONE SCREEN
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Order and Batch Open-Close LifecycleHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions

Interview reports that mention this question

  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
  • Airbnb SWE Intern OA / Interviews: 122 Experiences (Part 1 of 7)

Airbnb interview experiences

  • Airbnb SWE OA: Four-Level Banking System: 1 Experience
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public int[] pourWater(int[] heights, int volume, int k) {
      // Write your code here.
    }
}
Checking account…