FastPrepNext Generation of a Cell Grid
Problems/Next Generation of a Cell Grid

Next Generation of a Cell Grid

Rippling logoRippling● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Here you return the grid after one step of live and dead cells under the four usual rules. Every cell changes at once, and spots outside the grid count as dead. Each cell has up to 8 neighbors, diagonals included. That neighbor rule is our choice as well. Returning the next grid, instead of changing the input in place, is our choice, because a function with no return value cannot be graded here. The grid sizes, limits and examples are also our own.

The one question named is the game of life, which the author calls a medium problem. They posted the review in March 2022, after a rejection for a senior software engineer role they had applied for via a recruiter.

The review gives no input format, limits, examples or follow-up questions.

Our version is about 80% the same as the reported question.

You are given an m x n grid board. Each cell is alive (1) or dead (0). The neighbors of a cell are the up to 8 cells around it: up, down, left, right and the four diagonals. Cells outside the grid do not exist, so they never count as live neighbors.

Every cell changes at the same moment, based only on the current grid:

  • A live cell stays alive if 2 or 3 of its neighbors are live.
  • A live cell that has 0 or 1 live neighbors, or 4 or more, becomes dead.
  • A dead cell comes alive if exactly 3 of its neighbors are live.
  • Every other dead cell stays dead.

Return the next grid: a new m x n grid that shows every cell after this one change.

Function

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

Examples

Example 1

board = [[0,0,0,0],[1,1,1,0],[0,0,0,0]]return = [[0,1,0,0],[0,1,0,0],[0,1,0,0]]
board
0123000001111020000
→
return
0123001001010020100
Moved or new

The middle live cell (row 1, column 1) has 2 live neighbors, so it stays alive. The live cells at (1, 0) and (1, 2) have 1 live neighbor each, so they die. The dead cells at (0, 1) and (2, 1) each touch all 3 live cells, so they come alive. Every other cell has fewer than 3 live neighbors and stays dead.

Example 2

board = [[1,1,1],[1,1,1]]return = [[1,0,1],[1,0,1]]
board
01201111111
→
return
01201011101
Moved or new

Each corner cell touches 3 live cells, so it stays alive. Each cell in the middle column touches 5 live cells, more than 3, so it dies.

Example 3

board = [[0,0,0],[0,1,0]]return = [[0,0,0],[0,0,0]]
board
01200001010
→
return
01200001000
Moved or new

The only live cell, at (1, 1), has 0 live neighbors, so it dies. Every dead cell touches at most 1 live cell, so none comes alive. The answer is all 0.

Constraints

  • m == board.length and n == board[i].length for every row
  • 1 <= m, n <= 50
  • board[i][j] is 0 or 1

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Apply a 2048 Board MoveGlean · PHONE SCREENGlean interview questions
  • Spiral Order with ObstaclesTemu · PHONE SCREENTemu interview questions
  • Incremental Hard Attention with a KV CacheOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Spiral Matrix TraversalByteDance · PHONE SCREENByteDance interview questions
  • S-Shaped Matrix TraversalFox Corporation · PHONE SCREEN
  • Longest Consecutive Same-Color LineGoogle · PHONE SCREENGoogle interview questions
  • Process Minesweeper Game OperationsAmperity · PHONE SCREENAmperity interview questions
  • Diagonal TraverseHive · PHONE SCREENHive interview questions
  • Build a Bird’s-Eye-View Height GridNVIDIA · PHONE SCREENNVIDIA interview questions
  • Multi-Channel Valid ConvolutionTesla · PHONE SCREENTesla interview questions

Interview reports that mention this question

  • Rippling SWE Loops and History: 23 Experiences (Part 10 of 12)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int[][] gameOfLife(int[][] board) {
        // Write your code here.
    }
}
Checking account…