← General Motors Interview Insights

General Motors·Machine Learning Engineer·Technical Phone Screen·Intermediate

IntermediateRejected
Jun 2026

Summary

Did a technical screen for an ML Engineer role at General Motors. It was basically a graph traversal problem and I thought it went fine, but got the rejection email a week later.

Questions Asked (1)

Q1

Given a 2D grid, count the number of distinct islands using only horizontal and vertical movement (no diagonals).

Algorithms & Data StructuresRoot Cause Analysis
Author's notes

It's a standard BFS/DFS grid problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use DFS/BFS to explore each island, then normalize its shape by translating coordinates relative to the starting cell and storing the set of relative positions. Count distinct normalized shapes to get the number of distinct islands.

Pro tip: Clarify whether islands are considered distinct based on shape only (translation invariant) or also rotation/reflection; the standard problem assumes translation only, but mentioning this shows attention to detail.

1. Clarify the problem

Confirm that distinctness is based on shape (translation invariant) and that movement is only horizontal/vertical. Ask if rotations/reflections count as distinct.

2. Choose traversal method

Use DFS or BFS to explore each island. Iterate through the grid; when encountering an unvisited '1', start a traversal to find all connected cells.

3. Normalize island shape

During traversal, record each cell's coordinates relative to the starting cell (e.g., subtract the start row and col). Store these relative coordinates in a set or list.

4. Store and count distinct shapes

Add the normalized shape (e.g., as a sorted tuple of coordinates) to a global set. After processing all islands, the set size is the number of distinct islands.

5. Analyze complexity and edge cases

Discuss time O(R*C) and space O(R*C) for visited and shape storage. Mention edge cases like empty grid, all water, or all land.

Key Points to Mention

  • Use DFS/BFS for connected component exploration.
  • Normalize island shape by translating coordinates relative to the starting cell.
  • Store normalized shapes in a set to automatically handle duplicates.
  • Time and space complexity: O(R*C) for both.
  • Handle edge cases: empty grid, no islands, single cell islands.
  • Distinguish from counting total islands (which doesn't require normalization).

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