Daily iOS
UIKit

Undoable game state

A tic-tac-toe game built with UIKit needs unlimited undo. What would you store to support undoing?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Instead of mutating one board in place, push each move made so far (cell position and player) onto an array in order; undo is a single removeLast(), and the board's shape is recomputed from this array every time.

Share a question