Lowest-Latency Path Down the Layers of a Service Mesh Matrix
Last updated: November 29, 2026
Quick Overview
Each row of a matrix is a layer of services and each value is a hop latency. Starting anywhere in the top row and moving to the cell directly below or diagonally below in each step, return the minimum total latency to reach the bottom row.
Meta
November 29, 20260
0
0 solved
Each row of a matrix is a layer of services and each value is a hop latency. Starting anywhere in the top row and moving to the cell directly below or diagonally below in each step, return the minimum total latency to reach the bottom row.
An easy Meta phone screen question with an infrastructure flavor. The interviewer checks a clean row-by-row DP and correct handling of the first and last columns, and may use it to lead into a harder variant.
What the Interviewer Expects
- Process rows top to bottom
- Take the min of the up-left, up and up-right predecessors
- Guard column bounds
- Return the min over the last row
- Use O(n) memory
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
- What if the next cell must be in a different column than the current one?
- How would you return the path itself?
- What if you may move to any column in the next row at a cost of the column distance?
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 n x n (or r x c) matrix of integers, possibly negative. A path takes one cell per row, and consecutive cells differ by at most one column. Return the minimum sum of a path from the top...
High-Level Design
Let best[j] be the minimum latency of any path ending at column j of the current row. For the next row, a cell at column j can be reached from j-1, j, or j+1 above, so `new[j] = row[j] + m...