Bird
0
0
LLDsystem_design~20 mins

Board, Player, Game classes in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Board Game Architect
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Identify the primary responsibility of the Game class

In a simple board game design, which of the following best describes the main responsibility of the Game class?

AManage the overall game flow, including turns and win conditions
BStore the positions of pieces on the board
CRepresent a player with their attributes and actions
DHandle user input and display the game interface
Attempts:
2 left
💡 Hint

Think about which class controls the sequence of play and decides when the game ends.

Architecture
intermediate
1:30remaining
Choose the best design for Player and Board interaction

Which design best supports a Player interacting with the Board in a turn-based game?

ABoard directly modifies Player attributes during a move
BPlayer has a method to make a move that updates the Board state
CGame class modifies Player and Board independently without interaction
DPlayer and Board communicate only through a global variable
Attempts:
2 left
💡 Hint

Consider which class should initiate changes to the board during a player's turn.

scaling
advanced
2:00remaining
Scaling the Board class for large games

For a game with a very large board (e.g., 1000x1000 cells), which approach best optimizes memory and performance?

AUse a sparse data structure to store only occupied cells
BCreate a separate Board instance for each player
CStore all cells in a 2D array regardless of occupancy
DStore only the last move and reconstruct board state on demand
Attempts:
2 left
💡 Hint

Think about how to avoid wasting memory on empty cells.

tradeoff
advanced
2:00remaining
Tradeoff between Player class complexity and Game class control

What is a key tradeoff when giving the Player class more decision-making logic versus centralizing logic in the Game class?

ACentralizing logic in Game always improves performance
BMore logic in Player reduces code reuse across different games
CMore logic in Player increases modularity but can complicate coordination
DCentralizing logic in Game makes Player classes harder to test
Attempts:
2 left
💡 Hint

Consider how distributing logic affects modularity and coordination.

component
expert
3:00remaining
Estimate capacity for concurrent games in a server

A server runs multiple concurrent games, each with 2 players and a 10x10 board. Each game requires 1MB memory and 5ms CPU per turn. The server has 16GB RAM and 2GHz CPU with 8 cores. Estimate the maximum number of games it can handle simultaneously without performance degradation.

AAbout 10,000 games limited by memory
BAbout 12,800 games limited by CPU
CAbout 16,000 games limited by memory
DAbout 3,200 games limited by CPU
Attempts:
2 left
💡 Hint

Calculate max games by dividing total resources by per-game usage, then find the bottleneck.