Level: Senior-Level
Round: Phone Screen · Type: Coding · Difficulty: 7/10 · Duration: 60 min · Interviewer: Unfriendly
Topics: Arrays, Graph Traversal, Matrix Traversal
Location: San Francisco, CA
Interview date: 2025-12-31
Got offer: False
I had a technical phone screen with a good interviewer. I didn't fully understand the question initially and rushed into coding, which led to insufficient time for optimization. I ultimately failed the round.
The question I received was:
You are given an m x n integer matrix terrain, and an array limits of size k. You must compute an array answer of size k such that for each limits[i]:
You are allowed to revisit cells multiple times, but points are only earned on the first visit. Return answer. Traversal ends once we meet a value in the grid that is >= than current limit.
Input: int[][] matrix, int[] limits
Output: int[] answer
Example:
{1,4,2,8} {0,4,0,8} {1,2,0,8}
limit = 8 => 9 limit = 2 => 3
{1,2,3}, 1 => [2,2] {2,5,7}, {3,5,1} {5,6,2}
result [5,8,1]
My approach and key insights:
I failed to correctly understand the problem statement initially, and I started coding prematurely. The problem involves graph/matrix traversal with certain constraints. The core idea is to explore the matrix while the value in current cell is less than given limit. This requires a backtracking or DFS approach. A key detail is to only count points on the first visit.
Preparation Tips: