Find Hall Cells Whose Airflow Reaches Both Datacenter Exhausts
Last updated: November 29, 2026
Quick Overview
Given a grid of floor elevations for a datacenter hall where air flows from a cell to a neighbor of equal or lower height, the west and north edges vent to one exhaust and the east and south edges to another. Return all cells from which air can reach both exhausts.
Microsoft
November 29, 20260
0
0 solved
Given a grid of floor elevations for a datacenter hall where air flows from a cell to a neighbor of equal or lower height, the west and north edges vent to one exhaust and the east and south edges to another. Return all cells from which air can reach both exhausts.
A reverse multi-source BFS problem used in Microsoft onsites, adapted from the two-ocean drainage puzzle to airflow in an Azure hall. The interviewer checks whether you avoid running a search from every cell and instead flood inward from each border.
What the Interviewer Expects
- Notice that searching from every cell is O((RC)^2)
- Reverse the flow: start from each exhaust's border cells
- Move to neighbors with height greater than or equal to the current cell
- Intersect the two reachable sets
- Analyze O(R x C)
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you count the cells instead of listing them on a huge grid?
- What changes if flow can only go strictly downhill?
- How would you support updates to a single cell's height?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: heights, an R x C grid of integers. Cells on the top row or left column touch exhaust A; cells on the bottom row or right column touch exhaust B. Air moves to a four-directional neighbor whos...
High-Level Design
Rather than asking where each cell drains, ask which cells can be reached when climbing up from each exhaust. Start a BFS from all border cells of exhaust A at once and move to a neighbor only if its ...