← Google Interview Insights

Google·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Jun 2026

Summary

Google SWE coding problem involving grid coverage with horizontal and vertical boards. Classic minimum cover type problem, felt like an online assessment style question.

Questions Asked (1)

Q1

Given an m×n binary grid where 0s represent holes, find the minimum number of boards needed to cover all holes. Each board covers either a full row (1×n) or a full column (m×1), and can overlap intact cells.

Algorithms & Data Structures
Author's notes

This is a minimum vertex cover problem on a bipartite graph, which I did not see at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a minimum vertex cover on a bipartite graph where left nodes are rows and right nodes are columns, and each hole at (i, j) creates an edge between row i and column j. By König's theorem, the minimum vertex cover size equals the maximum matching size, which can be computed efficiently using Hopcroft-Karp or DFS-based augmenting paths.

Pro tip: Clarify that boards can overlap and cover intact cells, so covering a hole only requires selecting its row or column; this reduces to covering all edges with minimum vertices. Mention that the problem is equivalent to finding the minimum number of lines (rows or columns) to cover all 0s in a binary matrix, a classic problem solvable in polynomial time.

1. Understand the problem and constraints

Restate the problem: given an m×n binary grid with 0s as holes, find the minimum number of full rows or full columns to cover all holes. Note that boards can overlap and cover intact cells, so covering a hole only requires selecting its row or column.

2. Model as a graph problem

Create a bipartite graph with left nodes representing rows and right nodes representing columns. For each hole at (i, j), add an edge between row i and column j. The goal is to select a minimum set of vertices (rows/columns) that covers all edges, i.e., a minimum vertex cover.

3. Apply König's theorem

Use König's theorem: in bipartite graphs, the size of the minimum vertex cover equals the size of the maximum matching. Thus, the problem reduces to finding a maximum matching in the bipartite graph.

4. Compute maximum matching

Implement a maximum matching algorithm such as Hopcroft-Karp (O(E√V)) or a simpler DFS-based augmenting path algorithm (O(VE)). Since the graph is bipartite, these are efficient for typical grid sizes.

5. Return the matching size

The size of the maximum matching is the minimum number of boards needed. Optionally, reconstruct the actual set of rows and columns from the matching to provide the specific boards.

Key Points to Mention

  • Bipartite graph modeling: rows and columns as vertices, holes as edges.
  • Minimum vertex cover problem and its equivalence to maximum matching via König's theorem.
  • Efficiency of algorithms: Hopcroft-Karp O(E√V) vs. simpler O(VE) DFS-based matching.
  • Handling edge cases: empty grid, no holes, all holes, and large grids.
  • Overlap allowance means we only need to cover each hole by at least one board, not avoid covering intact cells.
  • Reconstruction of the actual board placement from the matching (optional but shows depth).

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