The "Champagne Tower interview question" is a simulation of liquid flowing through a pyramid of glasses. Champagne is poured into the top glass. Once a glass is full (holding 1 unit), any excess champagne flows equally into the two glasses below it. Given the total amount of champagne poured and a specific glass location (row and index), you need to find how much champagne is in that glass.
Google and TikTok use the "Champagne Tower coding problem" to test a candidate's ability to implement a "Dynamic Programming" or "Simulation" approach. It requires careful state management and an understanding of how value distributes across a 2D structure. It evaluates "Array interview pattern" skills, specifically handling boundaries and overflow.
This problem uses Dynamic Programming or Iterative Simulation.
row i has i+1 glasses.(0, 0).(r, c) has more than 1 unit:
extra = (amount - 1) / 2.0.extra to the two glasses below: (r+1, c) and (r+1, c+1).Pour 2 units.
Pyramid-shaped problems are common in "Dynamic Programming" interviews. Practice mapping the relationship between dp[i][j] and its children dp[i+1][j] and dp[i+1][j+1]. This pattern is also seen in problems like Pascal's Triangle.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Paint Fence | Medium | Solve | |
| Knight Dialer | Medium | Solve | |
| Ways to Express an Integer as Sum of Powers | Medium | Solve | |
| Count Ways To Build Good Strings | Medium | Solve | |
| Domino and Tromino Tiling | Medium | Solve |