Game of life step
Given an m x n board of 0s (dead) and 1s (live), compute the next state under Conway's Game of Life and return it as a new board. Each cell's eight neighbors determine its fate: a live cell survives with 2 or 3 live neighbors (else dies); a dead cell becomes live with exactly 3 live neighbors. Cells outside the board are treated as dead. The board has at least one cell.
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.
0:00 of about 25 min
solution.py
InputExpectedGot
[[[0,1,0],[0,0,1],[1,1,1],[0,0,0]]][[0,0,0],[1,0,1],[0,1,1],[0,1,0]]not run yetsample