Snake and Ladder Game – Low Level Design Interview Practice
Practise the Snake and Ladder Game low level design problem the way an LLD round actually runs. You are asked for requirements first, then a class model, and then to extend the design when a new requirement lands part way through – the follow-up that separates a design that was memorised from one that was understood.
The round checks the things interviewers grade: whether your classes carry single responsibilities, whether you reached for a design pattern or reinvented one, whether the design absorbs a new requirement without rewriting what exists, and whether you can explain a trade-off out loud. Feedback covers class modelling, SOLID principles, use of patterns, extensibility and communication.
What this question is really testing
An SDE-1 problem that rewards clean modelling over cleverness: build the board so that snakes and ladders are one concept, not two.
Requirements to establish first
- A board of N cells with entries that move a player from one cell to another.
- Two or more players taking turns, each rolling one or more dice.
- A player landing on a jump start moves to its end, in either direction.
- The game ends when a player reaches the final cell exactly, or overshoots, depending on the rule you choose.
- Report whose turn it is and the position of every player.
Core classes
- Board – Holds the cells and answers "where does this position actually take me?".
- Jump – A start and an end. A snake is a jump where end < start; a ladder is one where end > start. One class, not two.
- Player – Identity and current position. Nothing about rules.
- Dice – Roll count and faces, so a two-dice variant is a constructor argument.
- Game – Owns the turn order and the end condition.
Design patterns that apply
- Builder – A board is configured, not constructed: size, jump list, dice count, player list. A six-argument constructor is what this replaces.
- Strategy – Only if the win rule varies - exact landing versus overshoot. If it does not vary, say so rather than adding a pattern for its own sake.
Follow-up questions to expect
- A player rolling a six rolls again. Where does that live without the Game class knowing about dice faces?
- Add a cell that sends a player back to start. Is that a Jump with end 0, or something new?
- Two players land on the same cell. Does the second one bump the first, and what does that do to your position model?
Where candidates lose marks
- Separate Snake and Ladder classes with identical fields and duplicated lookup code.
- Storing jumps in a list and scanning it each turn, rather than a map from start cell.
- Putting the dice roll inside Player, which makes the game untestable without a fixed seed.