Level: Intern
Round: Full Journey · Type: Coding · Difficulty: 7/10 · Duration: 120 min · Interviewer: Unfriendly
Topics: Graph Traversal, BFS, Manhattan Distance, Connected Components
Location: San Francisco Bay Area
Interview date: 2026-01-15
Got offer: False
Question: Given an N*M rectangular garden, plant k types of crops with specified quantities for each crop such that crops of the same type are connected.
Question: Given an N*N matrix with 1 representing water and 0 representing land, find the shortest path from entrance S to exit T using only land. I needed to provide the idea and time/space complexity without writing code. The follow-up was to find a path that maximizes the minimum Manhattan distance to a cat located at some position in the matrix.
The question involved planting k types of crops in an N * M rectangular garden. Each crop type had a specified quantity, and the sum of all quantities equaled N*M. The goal was to generate a garden where each crop type was planted and crops of the same type were connected.
Follow-up:
The follow-up question involved a shape formed by vertically concatenating an N*N square with an M*M square. The total number of crops was N^2 + M^2. The task was to generate a planting arrangement for this new shape.
The initial problem was to find the shortest path from entrance S to exit T in an N*N matrix, where 1 represents water and 0 represents land. I could only traverse land cells. I was asked to describe the approach and its time/space complexity without writing code. I suggested BFS.
Follow-up: In the follow-up, a cat was introduced at a specific location in the matrix. The objective was to find a path from S to T that maximizes the minimum Manhattan distance to the cat. I initially considered using BFS with a heap, and the interviewer agreed with my approach. However, I didn't manage to implement it successfully.