> ## Documentation Index
> Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Low Level Design (LLD)

> Master object-oriented design and build real-world systems

<Frame>
  <img src="https://mintcdn.com/devweeekends/sTu6A4whRFPJo0_g/images/LLD/lld-hero.svg?fit=max&auto=format&n=sTu6A4whRFPJo0_g&q=85&s=d2c8f2cac6eae8cf91e9af9619eae8bc" alt="Low Level Design" width="1080" height="1080" data-path="images/LLD/lld-hero.svg" />
</Frame>

## 🚀 What is Low Level Design?

Low Level Design (LLD) is the **bridge between system architecture and working code**. While High Level Design (HLD) answers "what components do we need?", LLD answers "how do we implement each component with clean, maintainable, extensible code?".

Think of it this way: HLD is the city plan that decides where to place hospitals, schools, and roads. LLD is the architectural blueprint for each individual building -- the floor plan, wiring, plumbing, and structural engineering. Both are essential, but LLD is where abstract ideas become concrete, testable, production-grade software.

<CardGroup cols={3}>
  <Card title="Classes & Objects" icon="cubes" color="#3b82f6">
    Design classes, interfaces, and their relationships using OOP principles
  </Card>

  <Card title="Design Patterns" icon="puzzle-piece" color="#8b5cf6">
    Apply proven Gang of Four solutions to common problems
  </Card>

  <Card title="Clean Code" icon="wand-magic-sparkles" color="#10b981">
    Write maintainable, extensible, testable code using SOLID
  </Card>
</CardGroup>

<Tip>
  **LLD vs HLD**: HLD deals with services, databases, and infrastructure at 10,000 feet. LLD zooms into a single service to design classes, methods, and code structure. Master both for complete system design interviews!
</Tip>

***

## 📊 Course Stats

<CardGroup cols={4}>
  <Card title="6+" icon="book">
    Case Studies
  </Card>

  <Card title="23" icon="shapes">
    Design Patterns
  </Card>

  <Card title="5" icon="compass">
    SOLID Principles
  </Card>

  <Card title="45 min" icon="clock">
    Interview Framework
  </Card>
</CardGroup>

***

## ✅ Prerequisites

Before diving into LLD, make sure you're comfortable with:

<AccordionGroup>
  <Accordion title="Programming Fundamentals" icon="code">
    * Variables, functions, loops, conditionals
    * Basic data structures (arrays, dictionaries, sets)
    * At least one OOP language (Python, Java, C++, TypeScript)
  </Accordion>

  <Accordion title="Basic OOP Concepts" icon="object-group">
    * Classes and objects
    * Methods and attributes
    * Basic inheritance

    *Don't worry if you're rusty - we cover these in depth!*
  </Accordion>
</AccordionGroup>

***

## 🎯 Learning Path

Follow this structured 4-week journey to master LLD:

```mermaid theme={null}
graph LR
    A[Week 1: OOP Fundamentals] --> B[Week 2: SOLID Principles]
    B --> C[Week 3: Design Patterns]
    C --> D[Week 4: Case Studies]
    
    style A fill:#3b82f6,stroke:#1d4ed8,color:#fff
    style B fill:#8b5cf6,stroke:#6d28d9,color:#fff
    style C fill:#10b981,stroke:#047857,color:#fff
    style D fill:#f59e0b,stroke:#d97706,color:#fff
```

<Steps>
  <Step title="Week 1: Master OOP Fundamentals">
    **Goal**: Build a rock-solid foundation with the four pillars of OOP

    <CardGroup cols={2}>
      <Card title="OOP Concepts" icon="object-group" href="/lld/oop-concepts">
        Encapsulation, Abstraction, Inheritance, Polymorphism
      </Card>

      <Card title="OOP Deep Dive" icon="graduation-cap" href="/lld/oop/introduction">
        Beginner-friendly explanations with real-world examples
      </Card>
    </CardGroup>

    **Practice**: Build a simple `BankAccount` class with proper encapsulation
  </Step>

  <Step title="Week 2: Learn SOLID Principles">
    **Goal**: Write code that's easy to maintain, test, and extend

    <CardGroup cols={2}>
      <Card title="SOLID in Practice" icon="compass-drafting" href="/lld/solid-practice">
        Real refactoring examples for each principle
      </Card>

      <Card title="SOLID Deep Dive" icon="wand-magic-sparkles" href="/lld/solid/introduction">
        Step-by-step guide with before/after comparisons
      </Card>
    </CardGroup>

    **Practice**: Refactor a "God class" into well-separated components
  </Step>

  <Step title="Week 3: Study Design Patterns">
    **Goal**: Learn the Gang of Four patterns and when to apply them

    <CardGroup cols={2}>
      <Card title="Design Patterns" icon="shapes" href="/lld/design-patterns">
        Creational, Structural, and Behavioral patterns
      </Card>

      <Card title="UML Diagrams" icon="diagram-project" href="/lld/uml-diagrams">
        Class diagrams and sequence diagrams for interviews
      </Card>
    </CardGroup>

    **Focus on**: Factory, Strategy, Observer, State, Singleton (covers 80% of interviews)
  </Step>

  <Step title="Week 4: Practice Case Studies">
    **Goal**: Apply everything to real-world problems under time pressure

    <CardGroup cols={3}>
      <Card title="Parking Lot" icon="square-parking" href="/lld/case-parking-lot">
        🟢 Beginner
      </Card>

      <Card title="Vending Machine" icon="box" href="/lld/case-vending-machine">
        🟢 Beginner - State Pattern
      </Card>

      <Card title="LRU Cache" icon="database" href="/lld/case-lru-cache">
        🟡 Intermediate - Data Structures
      </Card>

      <Card title="Movie Ticket" icon="ticket" href="/lld/case-movie-ticket">
        🟡 Intermediate - Concurrency
      </Card>

      <Card title="Chess Game" icon="chess" href="/lld/case-chess">
        🟡 Intermediate
      </Card>

      <Card title="Elevator" icon="elevator" href="/lld/case-elevator">
        🔴 Advanced
      </Card>
    </CardGroup>

    **Practice**: Time yourself - complete each case study in 45 minutes
  </Step>
</Steps>

***

## 🏆 Why LLD Matters for Interviews

LLD rounds are **make-or-break** at top tech companies. They test if you can translate high-level ideas into working, maintainable, production-ready code. Unlike algorithm rounds that test raw problem-solving, LLD rounds reveal how you think about software at scale -- your instincts about where to draw class boundaries, when to reach for a pattern, and how to communicate trade-offs. This is the round that separates engineers who write code from engineers who design systems.

<Info>
  **Companies with LLD Rounds**: Google, Amazon, Microsoft, Meta, Apple, Uber, Airbnb, Stripe, and most Series B+ startups include LLD in their interview process.
</Info>

<CardGroup cols={2}>
  <Card title="Object-Oriented Thinking" icon="sitemap">
    Can you identify the right abstractions and model real-world entities as classes?
  </Card>

  <Card title="Pattern Recognition" icon="lightbulb">
    Do you recognize when to apply Factory, Strategy, Observer, State patterns?
  </Card>

  <Card title="Code Quality" icon="code">
    Is your code clean, readable, following naming conventions and best practices?
  </Card>

  <Card title="Trade-off Analysis" icon="scale-balanced">
    Can you explain WHY you chose one approach over another with pros/cons?
  </Card>

  <Card title="Extensibility" icon="puzzle-piece">
    Can your design handle new requirements without rewriting existing code?
  </Card>

  <Card title="Edge Case Handling" icon="shield-halved">
    Do you consider concurrency, errors, null cases, and boundary conditions?
  </Card>
</CardGroup>

### What Interviewers Actually Evaluate

| Criteria                  | Weight | What They Look For                                             |
| ------------------------- | ------ | -------------------------------------------------------------- |
| **Requirement Gathering** | 10%    | Do you ask the right clarifying questions?                     |
| **Class Design**          | 25%    | Are your classes well-named, single-purpose, properly related? |
| **Design Patterns**       | 20%    | Do you apply appropriate patterns without over-engineering?    |
| **Code Quality**          | 20%    | Is your code clean, readable, and following conventions?       |
| **SOLID Principles**      | 15%    | Does your design follow SOLID? Can you explain violations?     |
| **Communication**         | 10%    | Did you explain your thinking throughout the process?          |

***

## 📋 The LLD Interview Framework (45 min)

Master this framework to ace any LLD interview:

<Tabs>
  <Tab title="Overview">
    ```
    ┌─────────────────────────────────────────────────────────────┐
    │  PHASE 1: Requirements (5 min)                              │
    │  ├── Clarify scope and constraints                         │
    │  └── Identify actors and use cases                         │
    ├─────────────────────────────────────────────────────────────┤
    │  PHASE 2: Core Design (20 min)                              │
    │  ├── Identify entities and relationships                   │
    │  ├── Draw class diagram                                     │
    │  └── Define key interfaces and methods                     │
    ├─────────────────────────────────────────────────────────────┤
    │  PHASE 3: Deep Dive (15 min)                                │
    │  ├── Implement core logic                                   │
    │  ├── Apply design patterns                                  │
    │  └── Handle edge cases                                      │
    ├─────────────────────────────────────────────────────────────┤
    │  PHASE 4: Discussion (5 min)                                │
    │  ├── Explain trade-offs                                     │
    │  └── Discuss extensions                                     │
    └─────────────────────────────────────────────────────────────┘
    ```
  </Tab>

  <Tab title="Phase 1: Requirements">
    **Ask these questions BEFORE designing:**

    1. **Scope**: What are the core features? What's out of scope?
    2. **Users**: Who are the actors? (Customer, Admin, System)
    3. **Scale**: Single instance or distributed?
    4. **Constraints**: Any specific tech requirements?

    **Example for Parking Lot:**

    * How many floors? Types of vehicles?
    * Multiple entry/exit points?
    * Payment methods needed?
    * Real-time availability display?
  </Tab>

  <Tab title="Phase 2: Core Design">
    **Follow this checklist:**

    1. **List Nouns** → These become your classes
    2. **List Verbs** → These become your methods
    3. **Identify Relationships**:
       * Is-A (Inheritance)
       * Has-A (Composition/Aggregation)
       * Uses (Dependency)
    4. **Draw Class Diagram** with key attributes and methods
    5. **Define Interfaces** for polymorphic behavior
  </Tab>

  <Tab title="Phase 3: Deep Dive">
    **Implementation priorities:**

    1. Start with **core happy path**
    2. Apply **SOLID principles** as you code
    3. Identify and apply **design patterns**:
       * Factory for object creation
       * Strategy for interchangeable algorithms
       * Observer for event handling
       * State for complex state machines
    4. Handle **edge cases**:
       * Null/empty inputs
       * Concurrent access
       * Resource exhaustion
  </Tab>

  <Tab title="Phase 4: Discussion">
    **Be ready to discuss:**

    * Why did you choose X over Y?
    * How would you add feature Z?
    * What are the trade-offs of your design?
    * How would you handle 10x scale?
    * Where would you add caching/logging?
  </Tab>
</Tabs>

***

## 📚 Common LLD Interview Problems

### By Difficulty Level

<AccordionGroup>
  <Accordion title="🟢 Beginner (Start Here)" icon="seedling">
    | Problem                | Key Concepts                 | Case Study                      |
    | ---------------------- | ---------------------------- | ------------------------------- |
    | **Parking Lot**        | OOP basics, Strategy pattern | [View →](/lld/case-parking-lot) |
    | **Library Management** | CRUD, Relationships          | [View →](/lld/case-library)     |
    | **Vending Machine**    | State pattern, Inventory     | Coming Soon                     |
    | **ATM System**         | State pattern, Transactions  | [View →](/lld/case-atm)         |
  </Accordion>

  <Accordion title="🟡 Intermediate (Build Skills)" icon="fire">
    | Problem                  | Key Concepts                  | Case Study                        |
    | ------------------------ | ----------------------------- | --------------------------------- |
    | **Elevator System**      | State pattern, Scheduling     | [View →](/lld/case-elevator)      |
    | **Chess Game**           | Polymorphism, Command         | [View →](/lld/case-chess)         |
    | **Hotel Booking**        | Reservation, Concurrency      | [View →](/lld/case-hotel-booking) |
    | **Movie Ticket Booking** | Seat allocation, Transactions | [Start →](/lld/case-movie-ticket) |
    | **Food Delivery App**    | Multiple actors, State        | Coming Soon                       |
    | **Online Shopping Cart** | Order flow, Discounts         | Coming Soon                       |
  </Accordion>

  <Accordion title="🔴 Advanced (Master Level)" icon="crown">
    | Problem                     | Key Concepts                  | Case Study  |
    | --------------------------- | ----------------------------- | ----------- |
    | **Ride Sharing (Uber/Ola)** | Matching, Real-time, Location | Coming Soon |
    | **Social Media Feed**       | Observer, Timeline, Caching   | Coming Soon |
    | **Stock Exchange**          | Order matching, Concurrency   | Coming Soon |
    | **Splitwise**               | Graph, Debt simplification    | Coming Soon |
    | **Rate Limiter**            | Token bucket, Sliding window  | Coming Soon |
  </Accordion>
</AccordionGroup>

### By Design Pattern Focus

| Pattern           | Best Practice Problems                                                                        |
| ----------------- | --------------------------------------------------------------------------------------------- |
| **Strategy**      | Payment processing, Shipping methods, [Pricing](/lld/case-movie-ticket)                       |
| **Factory**       | Vehicle creation, Notification channels                                                       |
| **Observer**      | Stock alerts, Order status, [Movie Booking](/lld/case-movie-ticket)                           |
| **State**         | Order lifecycle, [Elevator](/lld/case-elevator), [Vending Machine](/lld/case-vending-machine) |
| **Decorator**     | Coffee shop, Pizza toppings, Permissions                                                      |
| **Singleton**     | Database connection, Configuration, Logger                                                    |
| **HashMap + DLL** | [LRU Cache](/lld/case-lru-cache), Browser History                                             |

***

## 🔧 Quick Reference: Core Concepts

### The Four Pillars of OOP

```python theme={null}
# ENCAPSULATION - Hide internal state
class BankAccount:
    def __init__(self):
        self.__balance = 0  # Private
    
    def deposit(self, amount):  # Controlled access
        if amount > 0:
            self.__balance += amount

# ABSTRACTION - Hide complexity
class PaymentProcessor(ABC):
    @abstractmethod
    def process(self, amount): pass  # What, not how

# INHERITANCE - Share behavior
class Car(Vehicle):
    def __init__(self):
        super().__init__()  # Reuse parent

# POLYMORPHISM - Same interface, different behavior
def make_sound(animal: Animal):
    animal.speak()  # Works for Dog, Cat, Bird...
```

### SOLID Principles One-Liners

| Principle                 | Rule                            | Example                                      |
| ------------------------- | ------------------------------- | -------------------------------------------- |
| **S**ingle Responsibility | One class, one reason to change | `Order` shouldn't send emails                |
| **O**pen/Closed           | Extend, don't modify            | Add new `PaymentMethod`, don't edit old ones |
| **L**iskov Substitution   | Subtypes are substitutable      | `Penguin` shouldn't break `Bird.fly()`       |
| **I**nterface Segregation | Small, focused interfaces       | `Readable` vs `ReadableWritable`             |
| **D**ependency Inversion  | Depend on abstractions          | Inject `Database`, not `PostgreSQL`          |

### Pattern Quick Reference

```python theme={null}
# SINGLETON - One instance
class Logger:
    _instance = None
    def __new__(cls):
        if not cls._instance:
            cls._instance = super().__new__(cls)
        return cls._instance

# FACTORY - Create without specifying class
def create_vehicle(type: str) -> Vehicle:
    return {"car": Car, "bike": Bike}[type]()

# STRATEGY - Swappable algorithms
class PaymentContext:
    def __init__(self, strategy: PaymentStrategy):
        self.strategy = strategy
    def pay(self, amount):
        return self.strategy.process(amount)

# OBSERVER - Notify on changes
class Stock:
    def __init__(self):
        self.observers = []
    def notify(self):
        for obs in self.observers:
            obs.update(self)
```

***

## 📖 Case Studies

<CardGroup cols={2}>
  <Card title="🅿️ Parking Lot System" icon="square-parking" href="/lld/case-parking-lot">
    Multi-floor parking with different vehicle types, pricing, and slot allocation
    <br /><Badge>Beginner</Badge> <Badge>Strategy Pattern</Badge>
  </Card>

  <Card title="📚 Library Management" icon="book" href="/lld/case-library">
    Books, members, borrowing, fines, and reservations with search
    <br /><Badge>Beginner</Badge> <Badge>CRUD</Badge>
  </Card>

  <Card title="🛗 Elevator System" icon="elevator" href="/lld/case-elevator">
    Multiple elevators with smart scheduling algorithms
    <br /><Badge>Intermediate</Badge> <Badge>State Pattern</Badge>
  </Card>

  <Card title="♟️ Chess Game" icon="chess" href="/lld/case-chess">
    Full chess implementation with piece movement and game rules
    <br /><Badge>Intermediate</Badge> <Badge>Polymorphism</Badge>
  </Card>

  <Card title="🏨 Hotel Booking" icon="hotel" href="/lld/case-hotel-booking">
    Room booking, reservations, and cancellation with concurrency
    <br /><Badge>Intermediate</Badge> <Badge>Transactions</Badge>
  </Card>

  <Card title="🏧 ATM System" icon="building-columns" href="/lld/case-atm">
    Cash withdrawal, deposits, and balance inquiry with state machine
    <br /><Badge>Beginner</Badge> <Badge>State Pattern</Badge>
  </Card>
</CardGroup>

***

## 💡 Pro Tips for LLD Interviews

<AccordionGroup>
  <Accordion title="Start Simple, Then Extend" icon="seedling">
    Don't try to build the perfect design upfront. Start with core classes that work, then add complexity. Interviewers want to see your iterative thinking. A senior engineer at Uber once described this as "make it work, make it right, make it extensible" -- in that exact order. Showing this progression in 45 minutes is what gets you a strong hire signal.
  </Accordion>

  <Accordion title="Think Out Loud" icon="comments">
    Explain your reasoning as you design. "I'm making this an interface because we might have multiple implementations" shows depth. The best candidates narrate their decision-making: "I could use inheritance here, but composition gives me more flexibility since payment methods change frequently." This signals that you are not just coding from memory -- you are making deliberate engineering trade-offs.
  </Accordion>

  <Accordion title="Ask Clarifying Questions" icon="circle-question">
    Don't assume. Ask about scale, users, and constraints. This shows you think like a senior engineer.
  </Accordion>

  <Accordion title="Know Your Patterns" icon="shapes">
    Memorize when to use Factory, Strategy, Observer, and State. These cover 80% of LLD interviews.
  </Accordion>

  <Accordion title="Consider Extensibility" icon="puzzle-piece">
    Design so new requirements don't require rewriting. "If we need to add X later, we just create a new class implementing Y."
  </Accordion>

  <Accordion title="Handle Edge Cases" icon="shield-halved">
    Mention concurrency, null checks, and error handling. Even if you don't implement them, show you're aware. A simple "I'd add a lock here to prevent two users from booking the same seat" demonstrates production-readiness thinking that separates mid-level from senior candidates. Interviewers at companies like Amazon specifically look for this awareness -- they call it "operational excellence."
  </Accordion>
</AccordionGroup>

***

## 🎯 Quick Links

<CardGroup cols={3}>
  <Card title="OOP Concepts" icon="object-group" href="/lld/oop-concepts">
    Foundation
  </Card>

  <Card title="SOLID Principles" icon="compass-drafting" href="/lld/solid-practice">
    Clean Code
  </Card>

  <Card title="Design Patterns" icon="shapes" href="/lld/design-patterns">
    Solutions
  </Card>

  <Card title="UML Diagrams" icon="diagram-project" href="/lld/uml-diagrams">
    Visualization
  </Card>

  <Card title="Interview Cheat Sheet" icon="file-lines" href="/lld/interview-cheatsheet">
    Quick Reference
  </Card>

  <Card title="Case Studies" icon="folder-open" href="/lld/case-parking-lot">
    Practice
  </Card>
</CardGroup>

***

## Interview Deep-Dive

<AccordionGroup>
  <Accordion title="An interviewer asks: 'Walk me through how you approach an LLD problem you have never seen before.' What is your framework?">
    **Strong Answer:**

    * I follow a four-phase framework. First, I spend about five minutes on requirements: clarifying scope, identifying actors, and asking what is explicitly out of scope. This prevents over-engineering.
    * Second, I spend twenty minutes on core design. I list nouns from the problem statement, which become classes. I list verbs, which become methods. I then map relationships: is-a for inheritance, has-a for composition, and uses for dependency. I sketch a class diagram with key attributes and methods only -- no boilerplate.
    * Third, I spend fifteen minutes on implementation. I code the happy path first, then layer in design patterns where they solve a real problem (not to show off). I mention edge cases even if I do not fully implement them.
    * Fourth, I spend five minutes discussing trade-offs: why I chose one approach over another, how the design handles new requirements, and where I would add caching, logging, or concurrency controls in production.
    * The key insight is that I start simple and iterate. An interviewer would rather see a clean three-class design that you evolve than a ten-class over-engineered design that you cannot explain.

    **Follow-up: How do you decide whether to use inheritance or composition when modeling relationships?**

    I apply the "is-a" test strictly. If the relationship is genuinely an identity relationship that will remain stable over time -- for example, a Dog is-a Animal -- inheritance is appropriate. But if the relationship involves behaviors that might change or be mixed at runtime -- for example, payment methods or notification channels -- I reach for composition and the Strategy pattern. The Gang of Four guideline "favor composition over inheritance" exists because inheritance creates tight coupling that is expensive to undo. In a real interview, I would say something like: "I could use inheritance here, but the payment method might change at runtime, so composition gives me the flexibility to swap strategies without modifying existing classes."
  </Accordion>

  <Accordion title="You are designing a system and the interviewer says: 'Your design has a God class. How would you fix it?' How do you respond?">
    **Strong Answer:**

    * A God class is one that has accumulated too many responsibilities. The fix is systematic application of the Single Responsibility Principle. I would identify each distinct "reason to change" in the class -- for example, if an OrderManager handles data persistence, email notifications, pricing calculations, and PDF generation, those are four separate reasons to change.
    * I would extract each responsibility into its own class: OrderRepository for persistence, NotificationService for emails, PricingService for calculations, InvoiceExporter for PDF generation. The original class becomes a thin coordinator (sometimes called a Facade) that delegates to these focused services.
    * The practical benefit is testability. A God class with five responsibilities requires mocking five different external systems to unit test. Five focused classes each require mocking at most one or two dependencies.
    * In an interview, I would physically draw the extraction on the whiteboard: show the original class, draw arrows to the new classes, and explain how each extracted class has a single, clear reason to change.

    **Follow-up: Is there ever a case where having a larger class is acceptable?**

    Yes. SRP does not mean every class should have one method. It means one reason to change. A PricingService might have methods for calculating discounts, applying taxes, and converting currencies -- but they all change for the same reason: pricing rules change. Over-splitting creates "class explosion" where you have dozens of tiny classes that are harder to navigate than one well-organized class. The judgment call is: would this class need to change for genuinely different reasons owned by different teams? If not, keeping related logic together is fine.
  </Accordion>

  <Accordion title="Explain how you would use UML in a 45-minute LLD interview. What would you draw, and what would you skip?">
    **Strong Answer:**

    * I draw a class diagram as my primary artifact. I start with three to five core classes showing just the class name and the relationship arrows. Then I progressively add key attributes and method signatures as the conversation evolves. I use proper UML notation for relationships: filled diamond for composition, open diamond for aggregation, dashed arrow with open triangle for interface implementation, and solid arrow with open triangle for inheritance.
    * I annotate multiplicity on every relationship. Saying "Customer has Orders" is vague. Writing "1 to 0..\*" is precise and shows the interviewer I think about cardinality.
    * I would skip sequence diagrams unless the interviewer specifically asks about a complex interaction flow (like a checkout process with multiple services). I would also skip use case diagrams entirely -- they are too high-level for LLD.
    * What I would not skip: visibility markers (+ for public, - for private, # for protected). Getting these right shows I am thinking about encapsulation at the design level, not just at the code level.

    **Follow-up: How do you decide between composition and aggregation in your class diagram?**

    The distinction is lifecycle ownership. Composition (filled diamond) means the contained object cannot exist without the container. If I delete an Order, the OrderItems die with it -- that is composition. Aggregation (open diamond) means the contained object has an independent lifecycle. If I dissolve a Team, the Players still exist -- that is aggregation. In practice, most relationships in LLD interviews are composition. I default to composition unless there is a clear reason why the contained object should outlive its container.
  </Accordion>

  <Accordion title="An interviewer asks: 'Which five design patterns would you prioritize for LLD interviews, and why those five?'">
    **Strong Answer:**

    * Factory, Strategy, Observer, State, and Singleton. These five cover roughly eighty to ninety percent of LLD interview scenarios.
    * Factory is essential because almost every system needs to create objects without coupling to concrete types. When the interviewer asks "how would you add a new vehicle type," Factory is the answer.
    * Strategy is the workhorse pattern for the Open/Closed Principle. Whenever you have interchangeable algorithms -- pricing rules, payment methods, sorting strategies, scheduling algorithms -- Strategy lets you add new behavior without modifying existing code.
    * Observer handles event-driven requirements: notifying users of stock price changes, sending order status updates, or broadcasting system alerts. It decouples the publisher from the subscriber.
    * State eliminates sprawling if/elif chains by modeling each state as its own class. ATM machines, elevator systems, vending machines, and order lifecycles are all state machine problems.
    * Singleton is simple but frequently tested. Database connections, configuration managers, and loggers are classic Singleton use cases. The key is knowing when Singleton is appropriate and when dependency injection is a better alternative.
    * I would mention Builder as a bonus for complex object construction, and Decorator for layered behavior (middleware, permissions), but those appear less frequently in interviews.

    **Follow-up: What is the difference between Strategy and State, since they look structurally similar?**

    They are structurally identical -- both delegate to an interface that has multiple implementations. The difference is intent and control flow. With Strategy, the client explicitly chooses which algorithm to use, and the choice is usually stable for the duration of an operation. With State, the object itself transitions between states, and the current state determines behavior. The state object typically triggers its own transitions. A good heuristic: if the behavior swap is driven by external configuration or user choice, it is Strategy. If the behavior swap is driven by internal lifecycle events, it is State.
  </Accordion>
</AccordionGroup>
