PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Applied

Scale Game of Life to huge matrices

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design space-efficient, I/O-aware algorithms and streaming or external-memory techniques for processing extremely large binary grids, with attention to neighbor counting and boundary handling in cellular automata.

  • medium
  • Applied
  • Coding & Algorithms
  • Software Engineer

Scale Game of Life to huge matrices

Company: Applied

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given starter code for computing one step of a **Game of Life–style** cellular automaton on a binary grid, but the naive implementation loads the entire matrix into memory. The input grid can be as large as **1,000,000 × 1,000,000**, so it cannot fit in RAM. ## Automaton rule - Each cell is either 0 (dead) or 1 (alive). - For each cell, count the 8 neighbors (up, down, left, right, diagonals). - Apply standard Game of Life rules: - Alive cell survives if it has 2 or 3 alive neighbors; otherwise it dies. - Dead cell becomes alive if it has exactly 3 alive neighbors. ## I/O model Assume the grid is stored on disk (e.g., one row at a time). You are provided helper functions similar to: - `readRow(i) -> array<int>` returns row `i` (0/1 values) - `writeRow(i, row)` writes the computed next-state row `i` ## Task Modify/implement the update so that it can process the full grid without OOM, using limited memory (e.g., O(W) or O(3W) where W is the number of columns). Be careful about: - Boundary rows/columns (treat missing neighbors as 0) - Ensuring correctness while streaming rows Return/produce the next grid on disk.

Quick Answer: This question evaluates a candidate's ability to design space-efficient, I/O-aware algorithms and streaming or external-memory techniques for processing extremely large binary grids, with attention to neighbor counting and boundary handling in cellular automata.

Related Interview Questions

  • Merge Overlapping Collinear Segments - Applied (hard)
  • Implement a Fixed-Capacity Deque - Applied (medium)
  • Implement Nested Transactional Key-Value Store - Applied (hard)
  • Merge overlapping 2D line segments - Applied (medium)
  • Find intersection of two line segments - Applied (easy)
Applied logo
Applied
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0
Loading...

You are given starter code for computing one step of a Game of Life–style cellular automaton on a binary grid, but the naive implementation loads the entire matrix into memory.

The input grid can be as large as 1,000,000 × 1,000,000, so it cannot fit in RAM.

Automaton rule

  • Each cell is either 0 (dead) or 1 (alive).
  • For each cell, count the 8 neighbors (up, down, left, right, diagonals).
  • Apply standard Game of Life rules:
    • Alive cell survives if it has 2 or 3 alive neighbors; otherwise it dies.
    • Dead cell becomes alive if it has exactly 3 alive neighbors.

I/O model

Assume the grid is stored on disk (e.g., one row at a time). You are provided helper functions similar to:

  • readRow(i) -> array<int> returns row i (0/1 values)
  • writeRow(i, row) writes the computed next-state row i

Task

Modify/implement the update so that it can process the full grid without OOM, using limited memory (e.g., O(W) or O(3W) where W is the number of columns).

Be careful about:

  • Boundary rows/columns (treat missing neighbors as 0)
  • Ensuring correctness while streaming rows

Return/produce the next grid on disk.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Applied•More Software Engineer•Applied Software Engineer•Applied Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.