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.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

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
Matrix Simulation
In-Place Encoding
Bit Manipulation
Hash Set
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported