0
0
LLDsystem_design~20 mins

Board and piece hierarchy in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Board and Piece Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding inheritance in board and piece hierarchy

In a board game design, which class should be the base class to represent all pieces on the board?

AA <strong>Game</strong> class that manages the rules and flow.
BA <strong>Player</strong> class that owns pieces.
CA <strong>Board</strong> class that contains all pieces and their positions.
DA generic <strong>Piece</strong> class that all specific pieces inherit from.
Attempts:
2 left
💡 Hint

Think about what all pieces share regardless of type.

Architecture
intermediate
1:30remaining
Designing the board class for scalability

Which design choice best supports a scalable board that can handle different game types and sizes?

AUse a fixed-size 2D array inside the <strong>Board</strong> class for all games.
BImplement the <strong>Board</strong> class with a dynamic data structure like a map or dictionary keyed by coordinates.
CStore pieces directly inside the <strong>Piece</strong> class without a board container.
DUse global variables to track piece positions outside any class.
Attempts:
2 left
💡 Hint

Consider flexibility for different board sizes and shapes.

scaling
advanced
2:00remaining
Handling piece movement validation efficiently

For a complex game with many piece types and movement rules, which approach best scales validation logic?

ADefine movement rules inside each <strong>Piece</strong> subclass using polymorphism.
BHardcode movement rules in the UI layer.
CUse a global function that checks moves for all pieces without class methods.
DPut all movement rules in a single large method inside the <strong>Board</strong> class.
Attempts:
2 left
💡 Hint

Think about how to keep code organized and easy to extend.

tradeoff
advanced
2:00remaining
Choosing between composition and inheritance for piece abilities

Which design choice balances flexibility and code reuse when pieces have multiple abilities?

AUse composition by creating separate ability classes and attaching them to pieces.
BUse deep inheritance chains where each subclass adds one ability.
CDuplicate ability code in each piece subclass that needs it.
DImplement all abilities in the base <strong>Piece</strong> class with flags.
Attempts:
2 left
💡 Hint

Consider how to add or remove abilities without rewriting classes.

estimation
expert
3:00remaining
Estimating memory usage for a large chess-like game

Estimate the approximate memory needed to store the state of a 100x100 board with 10,000 pieces, each piece storing position (2 integers), type (1 byte), and owner (1 byte). Assume 4 bytes per integer and ignore overhead.

AAbout 600 KB
BAbout 6 MB
CAbout 100 KB
DAbout 600 MB
Attempts:
2 left
💡 Hint

Calculate bytes per piece and multiply by number of pieces.