PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Airbnb

Simulate pouring water onto terrain

Last updated: Apr 19, 2026

Quick Overview

This question evaluates a candidate's ability to implement a discrete simulation and perform array manipulation while correctly handling deterministic scan rules, tie-breaking, and boundary conditions.

  • medium
  • Airbnb
  • Coding & Algorithms
  • Software Engineer

Simulate pouring water onto terrain

Company: Airbnb

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given an integer array `heights` representing a 1D terrain (each index is a column height), an integer `V` (units of water), and an index `K` where water is poured. Water is poured **one unit at a time** onto column `K`. For each unit: 1. It first tries to flow **left**: starting from `K`, move left while the next column is **not higher** than the current. Among all reachable positions on the left with the **minimum height**, the water settles at the **leftmost** such position. 2. If it cannot settle anywhere on the left (i.e., no strictly lower position than `heights[K]` was found by the left scan), it then tries to flow **right** symmetrically: move right while the next column is **not higher** than the current. Among all reachable positions on the right with the **minimum height**, the water settles at the **rightmost** such position. 3. If neither side offers a lower position, the water settles at `K`. After placing all `V` units, return the resulting `heights` array. ## Input - `heights`: array of non-negative integers - `V`: non-negative integer (units of water) - `K`: integer index (`0 <= K < len(heights)`) ## Output - The final `heights` array after all water is poured. ## Notes - Each water unit increases exactly one column height by `1`. - The “scan” rules above must be followed precisely (tie-breaking included).

Quick Answer: This question evaluates a candidate's ability to implement a discrete simulation and perform array manipulation while correctly handling deterministic scan rules, tie-breaking, and boundary conditions.

Related Interview Questions

  • Determine Exact Layover Booking - Airbnb (medium)
  • Implement Text Layout and Query Parsing - Airbnb (easy)
  • Find smallest permutation under constraints - Airbnb (medium)
  • Compute board-game score from regions - Airbnb (medium)
  • Construct smallest number from I/D pattern - Airbnb (medium)
Airbnb logo
Airbnb
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
29
0
Coding Console
Loading...

Problem

You are given an integer array heights representing a 1D terrain (each index is a column height), an integer V (units of water), and an index K where water is poured.

Water is poured one unit at a time onto column K. For each unit:

  1. It first tries to flow left : starting from K , move left while the next column is not higher than the current. Among all reachable positions on the left with the minimum height , the water settles at the leftmost such position.
  2. If it cannot settle anywhere on the left (i.e., no strictly lower position than heights[K] was found by the left scan), it then tries to flow right symmetrically: move right while the next column is not higher than the current. Among all reachable positions on the right with the minimum height , the water settles at the rightmost such position.
  3. If neither side offers a lower position, the water settles at K .

After placing all V units, return the resulting heights array.

Input

  • heights : array of non-negative integers
  • V : non-negative integer (units of water)
  • K : integer index ( 0 <= K < len(heights) )

Output

  • The final heights array after all water is poured.

Notes

  • Each water unit increases exactly one column height by 1 .
  • The “scan” rules above must be followed precisely (tie-breaking included).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Airbnb•More Software Engineer•Airbnb Software Engineer•Airbnb Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.