Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE
Problem: A Conway's Game of Life grid on a 4×4 board with alive cells at (1,0), (1,1), (1,2), (0,2) is advanced by one generation (standard rules; cells outside the board are dead). How many cells are alive after one generation?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: B. 4
Count live neighbours per cell, then apply the survival (2 or 3) and birth (exactly 3) rules to the whole board simultaneously. Updating cells in place while scanning changes the counts.
More Coding Interview Problems questions
- Problem: A list of 6 customers arrives at a bank counter with service times 4, 1, 3, 2, 6, 5 (in that arrival order). The counter serves…
- Problem: A linked list of 10 nodes is traversed with Floyd's tortoise and hare: the slow pointer moves 1 step and the fast pointer moves 2…
- Problem: An LRU cache holds 3 entries. Keys are accessed in this order: 1, 2, 3, 1, 4, 2, 5, 1, 3, 4. A key is a hit if it is already…
- Problem: Tower of Hanoi with 6 disks, moving all disks from peg A to peg C using peg B as the spare (standard rules). How many moves does…
- Problem: Count the integers from 1 to 999 whose decimal digit sum is divisible by 7.
- Problem: Compute Euler's totient φ(n) summed over n = 1 to 30 (φ(n) counts integers in [1, n] coprime to n, with φ(1) = 1).