← Figma Interview Insights

Figma·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Figma ML Engineer interview had a coding round with a grid traversal problem. Pretty standard stuff but worth knowing cold if you're going in.

Questions Asked (1)

Q1

Given a 2D grid where each cell is either land or water, count the number of distinct islands, where an island is a group of land cells connected in four directions.

Algorithms & Data Structures
Author's notes

Classic grid traversal.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a graph traversal algorithm like BFS or DFS to explore each unvisited land cell, marking all connected land cells as part of the same island. Iterate through the grid, and for each unvisited land cell, increment the island count and perform a traversal to mark the entire island.

Pro tip: Clarify whether diagonal connections count as part of the same island; if not, ensure your traversal only considers four directions. Also, discuss trade-offs between BFS and DFS, and consider iterative DFS to avoid recursion depth issues on large grids.

1. Understand the problem

Confirm that islands are defined by 4-directional connectivity and that you need to count distinct groups of land cells. Ask about grid size and constraints to choose the right approach.

2. Choose traversal method

Decide between BFS (using a queue) or DFS (using recursion or a stack). BFS is often safer for large grids due to recursion limits, but DFS is simpler to code.

3. Iterate and explore

Loop through each cell. When you find an unvisited land cell, increment the island count and start a traversal to mark all connected land cells as visited.

4. Mark visited cells

During traversal, mark cells as visited either by modifying the grid in-place (e.g., changing '1' to '0') or using a separate visited matrix to avoid revisiting.

5. Analyze complexity

State that time complexity is O(rows * cols) since each cell is visited once, and space complexity is O(min(rows, cols)) for BFS queue or O(rows * cols) for DFS recursion stack in worst case.

Key Points to Mention

  • 4-directional connectivity (up, down, left, right)
  • BFS vs DFS trade-offs
  • In-place modification vs separate visited set
  • Time and space complexity analysis
  • Handling edge cases like empty grid or all water
  • Potential follow-up: counting distinct island shapes (if asked)

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