Clarify the rules first (match length, simultaneous removal, gravity, cascades), then outline a loop that marks all cells in runs of 3+ in both directions, removes them, applies gravity column-wise, and repeats until no matches remain. Emphasize correctness and complexity, and mention optimizations like run-length encoding or union-find if time permits.
Pro tip: Explicitly state that all matches in a pass must be removed simultaneously to avoid order-dependent bugs, and that gravity is applied per column after removal. This shows you understand the subtle correctness requirements that trip up many candidates.
Confirm match length (3+), whether matches are removed simultaneously, gravity direction, and handling of empty cells. Ask about board size limits and whether diagonal matches count.
Scan each row and column to find runs of 3+ identical non-empty values. Mark all cells in these runs for removal in a boolean grid to ensure simultaneous removal.
Remove all marked cells (set to empty), then for each column, compact non-empty cells downward while preserving order. Count removed cells.
Repeat detection, removal, and gravity until a pass finds no matches. Return the final board and total removed count.
Discuss time complexity O(passes * m * n) and space O(m * n). Mention possible optimizations like run-length encoding, union-find, or early termination if no matches.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.