Cheapest Route for a Maintenance Cart Across a Data Center Floor
Last updated: November 29, 2026
Quick Overview
A grid gives the cost to cross each floor tile of a data center hall. Starting at the top-left tile and moving only right or down, return the minimum total cost to reach the bottom-right tile.
Meta
November 29, 20260
0
0 solved
A grid gives the cost to cross each floor tile of a data center hall. Starting at the top-left tile and moving only right or down, return the minimum total cost to reach the bottom-right tile.
Used as a warm-up in Meta phone screens before a harder second question. The interviewer checks that you can define a DP state precisely, handle the first row and column, and reduce memory to one row without bugs.
What the Interviewer Expects
- Recognize optimal substructure from the right/down move constraint
- Handle the first row and first column boundaries
- Fill in a single pass in row-major order
- Reduce to O(columns) memory
- Mention why Dijkstra is unnecessary here
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 also return the path itself?
- What changes if the cart may move in all four directions?
- What if some tiles are impassable?
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 is an r x c grid of non-negative integers with at least one cell. The cart starts on (0, 0) and must end on (r-1, c-1), paying the cost of every tile it stands on, including both endpoints...
High-Level Design
Because moves only go right or down, any path into cell (i, j) arrives from (i-1, j) or (i, j-1). So the cheapest cost to reach a cell is its own cost plus the cheaper of those two. Cells in the...