Skip to the guide

The framework end to end: tic-tac-toe in 40 minutes

BeginnerConcept7 pages

Tic-tac-toe is one of the smallest LLD questions: two players take turns placing X and O on a 3 by 3 board, and three in a row wins. This page runs it through the six steps of the LLD framework, minute by minute. The parking lot is the full 45-minute mock, and the next pages all use the code built here.

A nine-piece puzzle

A parent teaching a child jigsaws starts with a puzzle of nine pieces. They turn every piece face up and count them, sort the corners from the edges, and look at the picture on the box. They check which tabs fit which holes, build the frame, and fill in the middle. Last, they run a hand over the puzzle to feel for a gap. On nine pieces the child sees every step in a few minutes, and later the same steps finish a puzzle of a thousand pieces.

Tic-tac-toe is the nine-piece puzzle, with exactly nine cells, and the parking lot is the thousand-piece one. Turning the pieces face up is clarifying the requirements, and sorting them is finding the entities. The picture on the box is the class diagram. The tabs and holes are the method signatures, which say how each class fits the next. The frame is the core flow, and the middle is the new requirement. The hand feeling for gaps is the tests and the edge cases.