HARDasked at 1 company

Grid Illumination

A hard-tier problem at 38% community acceptance, tagged with Array, Hash Table. Reported in interviews at Dropbox and 0 others.

Founder's read

Grid Illumination is a hard problem that Dropbox loves to ask. It's one of those problems where the naive approach gets you killed on time complexity, and the trick isn't immediately obvious. You need to track which cells are illuminated by bulbs placed on a grid, then answer queries about whether specific cells are lit. The catch: bulbs illuminate entire rows, columns, and both diagonals. The acceptance rate sits at 38%, which tells you most people either TLE or miss the constraint interactions. If this hits your live OA and you blank on the indexing scheme, StealthCoder solves it in seconds.

Companies asking
1
Difficulty
HARD
Acceptance
38%

Companies that ask "Grid Illumination"

If this hits your live OA

Grid Illumination is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The core pattern is that each bulb lights up four infinite lines: its row, column, and both diagonals passing through it. The naive approach simulates the grid directly and checks all four lines for each query, but with grids up to 10^9 by 10^9, that's impossible. The real solution uses hash tables to count how many bulbs illuminate each row, column, and diagonal. Track the bulb positions themselves in a set, then for a query cell, check whether any of the four lines passing through it have nonzero counts. The tricky part is encoding diagonals correctly: use (row - col) for one diagonal and (row + col) for the other. Common pitfall is forgetting that a bulb on the same cell as a query doesn't count as illumination. StealthCoder handles the diagonal encoding and boundary logic automatically when you're stuck mid-OA.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Grid Illumination recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Grid Illumination interview FAQ

Why does the naive grid approach fail?+

The grid can be up to 10^9 by 10^9 cells. You can't allocate that memory or iterate it. You must use hash tables to track which rows, columns, and diagonals contain bulbs, then count how many bulbs affect each query in constant time.

How do you encode diagonals in a hash table?+

Use (row - col) for the main diagonal direction and (row + col) for the anti-diagonal. This way, all cells on the same diagonal have the same key. It's a standard technique in grid problems but easy to get wrong under time pressure.

Is this problem still asked at Dropbox?+

Dropbox is on the public record for asking it. Hard problems with hash table and array topics show up in their technical screen rounds. Expect the grid and diagonal constraints to be emphasized during the problem statement.

What's the time complexity after you solve it correctly?+

Preprocess bulb placement in O(n) where n is the number of bulbs. Each query runs in O(1) because you only check four lines. Total is O(n + q) for n bulbs and q queries, which passes even with 10^5 operations.

What's the most common mistake in this problem?+

Forgetting that a bulb at position (r, c) does not illuminate itself. The problem statement says bulbs illuminate rows, columns, and diagonals, but the cell containing the bulb is dark. This catches most people who treat the problem as a flood-fill or simple illumination problem.

Want the actual problem statement? View "Grid Illumination" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.