Trains the technique from
LeetCode 289Game of LifeThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A display panel holds lamps, each either lit as 1 or dark as 0. A lamp's neighbours are the cells touching it along an edge or at a corner, so up to eight of them.
On one tick every lamp changes at the same instant, and each one looks only at how many of its neighbours were lit just before the tick:
Return the panel as it stands after one tick.
Example 1
The middle lamp of the lit row keeps two lit neighbours and holds. The two ends have only one each and go dark. The cells straight above and below the middle each touch all three lit lamps, so they come on, leaving the row standing upright.
Example 2
Each lamp touches the other three, so every one of them has three lit neighbours and stays lit. Nothing changes.
Example 3
The dark top-left cell touches three lit lamps and comes on. The lit lamp in the bottom-right corner touches only one and goes out. Two more dark cells, the one right of centre and the one below centre, each touch exactly three lit lamps and come on.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def game_of_life(panel: list[list[int]]) -> list[list[int]]:public int[][] gameOfLife(int[][] panel)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.