Largest Plus-Shaped Antenna Array on a Grid With Dead Cells
Last updated: November 29, 2026
Quick Overview
On an n x n grid where every cell is a working antenna except a given list of dead cells, find the largest order k of an axis-aligned plus shape of working cells (a center with k-1 working cells extending up, down, left and right).
0
0
0 solved
On an n x n grid where every cell is a working antenna except a given list of dead cells, find the largest order k of an axis-aligned plus shape of working cells (a center with k-1 working cells extending up, down, left and right).
A Google onsite DP problem framed around antenna placement. The interviewer checks whether you compute four directional arm lengths in linear passes rather than expanding from every center, and whether you can combine them with a min.
What the Interviewer Expects
- Defines arm length in each of the four directions per cell
- Computes each direction in one linear sweep
- Takes the min of the four arms as the plus order at that cell
- Stores dead cells in a set for O(1) lookup
- Achieves O(n^2) time
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Count how many centers achieve the maximum order.
- Allow the plus arms to have different lengths and maximize total cells.
- The grid is 10^9 x 10^9 with few dead cells; how would you approach it?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
nanddead, a list of[r, c]cells. - Order k means the center plus k-1 working cells in each of four directions.
- Output: the maximum k, or 0 if every cell is dead....
High-Level Design
For a center, the plus order is the minimum of four counts: consecutive working cells going left (including the center), right, up and down. Each count can be computed for all cells with one sweep in ...