Week 14 — LLD Patterns & DP

advanced lld dsa dbms

Goal: Month 4 begins — learn the design patterns that show up in every LLD interview. By Friday you should be able to name, explain, and implement at least 7 patterns from memory.

Topics

DayFocusTopics
MonLLD Design PrinciplesDRY, KISS, and YAGNI · Coupling and Cohesion · Singleton Pattern
TueCreational & Structural PatternsFactory Pattern · Adapter Pattern · Decorator Pattern
WedStructural & Behavioral PatternsFacade Pattern · Observer Pattern · Strategy Pattern
ThuDSA Dynamic Programming2D DP Patterns · Knapsack Patterns
FriRedis Deep DiveRedis Data Types and Commands

Key Concepts

  • When Singleton becomes an anti-pattern — global state, hidden dependencies, testing nightmares
  • Factory vs Builder — Factory for object families, Builder for complex construction with many optional params
  • Adapter for incompatible interfaces — wrap a third-party class to match your expected interface
  • Decorator for runtime extension — add behavior without subclassing (think Java I/O streams)
  • Facade for simplified APIs — hide subsystem complexity behind a single clean interface
  • Observer for event systems — publisher-subscriber decoupling, the backbone of reactive programming
  • Strategy for interchangeable algorithms — swap sorting, pricing, or payment logic at runtime
  • 0/1 knapsack vs unbounded knapsack — the subtle difference that changes the entire DP transition
  • 2D DP grids — unique paths, minimum path sum, edit distance
  • Redis strings, lists, sets, sorted sets, hashes — know when to use each data structure

Practice

  • Implement the Observer pattern for a notification system (email + SMS + push subscribers)
  • Implement the Strategy pattern for a payment processor (credit card, PayPal, crypto)
  • Solve the 0/1 knapsack problem — then modify it for unbounded knapsack and compare
  • Use Redis CLI to model a leaderboard with sorted sets

~13 topics · ~1.5-2 hrs/day · Focus: read the linked notes, then code each concept