Code Room
CodingMediumcod-g651
Subject In place transformsLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given an m x n board of 0s (dead) and 1s (live), advance it ONE step of Conway's Game of Life and return the updated board. Rules: a live cell with <2 or >3 live neighbours dies; a live cell with 2 or 3 lives; a dead cell with exactly 3 live neighbours becomes alive. All cells update simultaneously from the previous state. Do it with O(1) extra space (in place) — encode the next state in the spare bit of each cell before decoding.

Implement
game_of_life(board: list[list[int]]) → list[list[int]]
Examples
in[[[0,1,0],[0,0,1],[1,1,1],[0,0,0]]]out[[0,0,0],[1,0,1],[0,1,1],[0,1,0]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.