Advance a Grid of Server Rack States One Tick In Place
Last updated: November 29, 2026
Quick Overview
Each cell of a rack grid is 1 (active) or 0 (idle). Apply Conway's Game of Life rules to compute the next state of every cell simultaneously, updating the grid in place with O(1) extra space.
0
0
0 solved
Each cell of a rack grid is 1 (active) or 0 (idle). Apply Conway's Game of Life rules to compute the next state of every cell simultaneously, updating the grid in place with O(1) extra space.
An onsite-style simulation question in Google's coding rounds, framed as modeling how activity spreads among neighboring racks in a data center. The interviewer cares about the in-place encoding trick (keeping old and new state in the same cell) and careful neighbor counting at the borders.
What the Interviewer Expects
- States the four rules precisely
- Explains why naive in-place updates corrupt neighbor counts
- Encodes old and new state in two bits of each cell
- Counts eight neighbors with correct boundary checks
- Discusses an unbounded or sparse board as a follow-up
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
- How would you handle an infinite board with few live cells?
- Parallelize the update across many machines; what data must neighbors exchange?
- Run k generations efficiently; when would you detect a repeating state?
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: an m x n list of lists of 0 and 1.
- Rules: a live cell with 2 or 3 live neighbors survives; any other live cell dies; a dead cell with exactly 3 live neighbors becomes live.
- All cells upda...
High-Level Design
Updating cells one by one would make later cells see some new values. To avoid an extra grid, store the next state in bit 1 while bit 0 keeps the current state. While counting neighbors, read only `ce...