FastPrepGame of Life: Next Generation
Problems/Game of Life: Next Generation

Game of Life: Next Generation

Meta logoMeta● MediumFULLTIMEONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Meta E5 machine-learning engineer candidate reports an unspecified variation of the linked Game of Life problem in a post-phone interview loop. The precise variation was not described. This practice uses the linked public one-generation rules and bounds, with a returned grid for the FastPrep judge. Source match is about 65%.

Given a rectangular grid board of dead cells (0) and live cells (1), return its state after one simultaneous Game of Life generation.

Each cell has up to eight neighbors: horizontal, vertical, and diagonal cells within the grid. A live cell survives with two or three live neighbors and otherwise dies. A dead cell becomes live with exactly three live neighbors and otherwise stays dead. Count all neighbors from the original grid before any update.

For this exercise, the grid is finite: cells outside it are dead. Return the complete next-state grid in the same dimensions.

Function

gameOfLife(board: int[][]) → int[][]

Examples

Example 1

board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]]return = [[0,0,0],[1,0,1],[0,1,1],[0,1,0]]
board
0120010100121113000
→
return
0120000110120113010
Moved or new

Apply the neighbor counts to the original four-row grid at the same time.

Example 2

board = [[1,1],[1,0]]return = [[1,1],[1,1]]
board
01011110
→
return
01011111
Moved or new

The dead lower-right cell has three live neighbors and becomes live; the others each have two neighbors and survive.

Example 3

board = [[0,0,0],[1,1,1],[0,0,0]]return = [[0,1,0],[0,1,0],[0,1,0]]
board
012000011112000
→
return
012001010102010
Moved or new

The three-cell horizontal line becomes a vertical line because updates occur simultaneously.

Constraints

  • 1 <= board.length, board[i].length <= 25.
  • Every row has the same length.
  • Every cell is 0 or 1.

More Meta Onsite Interview questions

  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
  • Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
  • Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
  • Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
  • Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
  • Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Random Bingo Card GeneratorUber · ONSITE INTERVIEWUber interview questions
  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Spiral MatrixAthenahealth · ONSITE INTERVIEW
  • Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Spiral MatrixNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Tic-Tac-Toe Move WinnersByteDance · ONSITE INTERVIEWByteDance interview questions
  • Trace Every Water Drop to Its Resting DestinationGoogle · ONSITE INTERVIEWGoogle interview questions
  • Cyclic Fuel Command SimulationWaymo · ONSITE INTERVIEWWaymo interview questions
  • Generate a Spiral MatrixMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Spiral Matrix with ObstaclesTemu · ONSITE INTERVIEWTemu interview questions

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public int[][] gameOfLife(int[][] board) {
        // Write your code here
    }
}
Checking account…