← Meta Interview Insights

Meta·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Coding round at Meta for an MLE role. One problem, grid manipulation, seemed straightforward but had a small gotcha that I almost missed.

Questions Asked (1)

Q1

Given a maze represented as a grid and a path as a list of (row, col) coordinates from entrance to exit, write a function that marks each cell along the path with '*', while keeping the entrance cell as 'e' and the exit cell as 'E'. Return the modified grid.

Algorithms & Data Structures
Author's notes

Jumped straight into iterating the path and marking everything with '*', then realized mid-explanation I was about to overwrite the entrance and exit too.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Iterate through the path list, and for each coordinate, update the grid cell to '*' except when the coordinate is the first (entrance) or last (exit) element of the path, which should be set to 'e' and 'E' respectively. This approach directly modifies the grid in-place and handles the special cases by checking indices.

Pro tip: Clarify assumptions about the input: whether the grid is mutable, if the path is guaranteed valid, and if the entrance/exit are already marked. This shows attention to detail and avoids edge-case bugs.

1. Understand the problem and constraints

Confirm that the grid is a list of lists of characters, the path is a list of (row, col) tuples from entrance to exit, and that you need to modify the grid in-place or return a new one. Ask about edge cases like empty path or single-cell path.

2. Iterate through the path with indices

Use a loop with index to access each coordinate. For each coordinate, determine if it's the first (entrance), last (exit), or an intermediate cell.

3. Update grid cells accordingly

For the first coordinate, set grid[row][col] = 'e'; for the last, set to 'E'; for all others, set to '*'. Ensure you handle the case where entrance and exit are the same cell (path length 1) by prioritizing 'e' or 'E' as per requirements.

4. Return the modified grid

After processing all coordinates, return the grid. If modifying in-place, you can return the same grid; otherwise, return a copy.

Key Points to Mention

  • Time complexity: O(n) where n is the length of the path, as we visit each coordinate once.
  • Space complexity: O(1) if modifying in-place, otherwise O(m*n) for a copy.
  • Handling of entrance and exit: explicitly check indices 0 and len(path)-1.
  • Edge cases: empty path, path with one cell, path with two cells (entrance and exit adjacent).
  • Assumption that path coordinates are within grid bounds and valid.
  • In-place modification vs. creating a new grid: discuss trade-offs.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.