Episode 9 — System Design / 9.6 — LLD Problem Solving
9.6 — Exercise Questions
How to use this material (instructions)
- Pick one problem per session and set a 45-minute timer.
- Follow the LLD Problem-Solving Template for each: requirements -> entities -> relationships -> APIs -> patterns -> code.
- Write code from scratch in your preferred editor — do not look at solutions.
- After your timer, compare your design with a peer or mentor.
- Repeat each problem at least twice over the course of your study plan — you will notice improvements.
Design Prompts
Each prompt includes the minimum set of features to implement. Go deeper if time permits.
1. Library Management System
Design a system for a public library.
Core features:
- Track books (title, author, ISBN, copies).
- Members can search, borrow, and return books.
- Maximum 5 books per member at a time.
- Calculate and charge late fees.
- Reservation system: if a book is unavailable, a member can reserve it and get notified when returned.
Think about: Observer pattern for notifications, Strategy pattern for fee calculation, Singleton for the Library.
2. ATM Machine
Design an ATM that allows users to check balance, withdraw, and deposit cash.
Core features:
- Authenticate user with card number and PIN.
- Check balance, withdraw cash (in denominations: 100, 500, 2000), deposit cash.
- ATM has limited cash in each denomination.
- Transaction history per account.
- Daily withdrawal limit.
Think about: State pattern (IDLE -> CARD_INSERTED -> AUTHENTICATED -> TRANSACTION), Chain of Responsibility for denomination dispensing.
3. Snake and Ladder Game
Design the classic board game for 2-4 players.
Core features:
- Board of 100 cells with configurable snakes and ladders.
- Players take turns rolling a dice (1-6).
- Landing on a snake head moves you down; landing on a ladder bottom moves you up.
- First player to reach or exceed cell 100 wins.
- Track game history (moves).
Think about: Single Responsibility (Board, Dice, Player, Game are separate), no complex patterns needed — focus on clean modeling.
4. Online Food Ordering System (Zomato/Swiggy)
Design the ordering flow for a food delivery platform.
Core features:
- Restaurants with menus (items, prices, availability).
- Customers browse restaurants, add items to cart, place orders.
- Order states: PLACED -> ACCEPTED -> PREPARING -> OUT_FOR_DELIVERY -> DELIVERED.
- Assign delivery partner (nearest available).
- Rating system for restaurants and delivery partners.
Think about: State pattern for order lifecycle, Strategy pattern for delivery partner matching, Observer for order status updates.
5. Tic-Tac-Toe
Design a flexible Tic-Tac-Toe game (not just 3x3).
Core features:
- Configurable board size (N x N).
- Two players (human or bot).
- Win condition: N marks in a row/column/diagonal.
- Undo move functionality.
- Game replay (store all moves).
Think about: Command pattern for undo, Strategy pattern for bot difficulty levels, clean win-checking algorithm.
6. Hotel Booking System
Design a hotel reservation system.
Core features:
- Hotel with multiple room types (Standard, Deluxe, Suite) with different pricing.
- Search available rooms for a date range.
- Book a room: check availability -> lock -> payment -> confirm.
- Cancel booking with refund policy (full refund if > 48hrs, 50% if > 24hrs, no refund otherwise).
- Seasonal/dynamic pricing.
Think about: Strategy pattern for pricing, Strategy pattern for refund policy, similar locking mechanism as BookMyShow.
7. Logging Framework
Design a configurable logging library (like Log4j).
Core features:
- Log levels: DEBUG, INFO, WARN, ERROR, FATAL.
- Multiple output destinations: Console, File, Database.
- Configurable log format (timestamp, level, message, context).
- Filter logs by level (e.g., only show WARN and above).
- Thread-safe singleton logger.
Think about: Singleton for Logger, Observer pattern for multiple destinations, Chain of Responsibility for level filtering, Strategy for formatting.
8. Chess Game
Design a two-player chess game.
Core features:
- 8x8 board with standard piece setup.
- Each piece type (King, Queen, Rook, Bishop, Knight, Pawn) has its own movement rules.
- Validate moves (cannot move into check, cannot jump over pieces except Knight).
- Detect check, checkmate, and stalemate.
- Move history and undo.
Think about: Each piece as a subclass with a getValidMoves() method (polymorphism), Command pattern for undo.
9. Notification Service
Design a notification delivery system.
Core features:
- Support multiple channels: Email, SMS, Push notification.
- Users set notification preferences (which channels they want).
- Notification templates with variable substitution.
- Priority levels (HIGH sends immediately, LOW batches).
- Retry failed notifications (max 3 attempts with exponential backoff).
Think about: Strategy pattern for channels, Template method for rendering, Observer for delivery, Queue for batching.
10. Stack Overflow (Q&A Platform)
Design a simplified Q&A platform.
Core features:
- Users can post questions and answers.
- Upvote/downvote questions and answers.
- Accept an answer (only by question author).
- Tags and search.
- Reputation system: +10 for upvote on answer, +5 for upvote on question, -2 for downvote.
Think about: Observer for reputation updates, clean entity modeling (User, Question, Answer, Vote, Tag).
11. Task Scheduler (Cron)
Design a task scheduling system.
Core features:
- Schedule tasks to run at specific times or intervals (every N minutes, hourly, daily, weekly).
- Support one-time and recurring tasks.
- Tasks have priorities; higher-priority tasks execute first when resources are limited.
- Track execution history (start time, end time, status, error).
- Cancel or pause scheduled tasks.
Think about: Priority queue, Strategy for scheduling policies, State for task lifecycle.
12. Car Rental System
Design a vehicle rental management system.
Core features:
- Multiple vehicle types (Sedan, SUV, Luxury) at multiple locations.
- Search available vehicles by type, location, and date range.
- Reservation flow: select -> reserve -> pickup -> return.
- Pricing: per-day rate + insurance + fuel charges.
- Late return penalty.
Think about: Strategy for pricing, Factory for vehicle creation, State for reservation lifecycle.
How to Self-Evaluate
After completing a design, check these criteria:
| Criteria | Question |
|---|---|
| Completeness | Did I cover all core features? |
| Entity clarity | Can I explain each class and its responsibility in one sentence? |
| Relationships | Are ownership (composition) and usage (dependency) clearly defined? |
| Extensibility | Can I add a new feature (e.g., new vehicle type, new notification channel) without modifying existing classes? |
| Patterns | Did I use design patterns where they naturally fit, not where they are forced? |
| Edge cases | Did I handle at least 3 edge cases? |
| Working code | Does my code actually run end-to-end for the happy path? |
Continue to -> 9.6-Interview-Questions