-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblems.cpp
More file actions
115 lines (66 loc) · 9.5 KB
/
Copy pathProblems.cpp
File metadata and controls
115 lines (66 loc) · 9.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
System to Design Key LLD Concepts to Emphasize
Parking Lot System Classes for ParkingLot, Floor, ParkingSpot (with inheritance for types like Compact, Large, etc.),
Vehicle, Ticket. Use Strategy Pattern for parking strategies.
Vending Machine State Pattern (e.g., IdleState, HasMoneyState, DispensingState),
classes for Item, Coin, VendingMachine. Focus on clear state transitions.
Traffic Control System State Pattern for traffic lights (Red, Yellow, Green), Observer Pattern for synchronizing lights at different intersections.
Elevator System Classes for Elevator, Floor, Request. Focus on the scheduling algorithm and concurrent handling of requests
(multithreading/concurrency concepts are key).
Movie Ticket Booking (BookMyShow/Cinemas) Classes for Movie, Show, CinemaHall, Seat, Booking. Use Observer Pattern
(e.g., updating seat availability). Focus on concurrency control for seat booking.
Logger / Logging System Singleton Pattern for the main Logger class, Chain of Responsibility Pattern for message severity
(Debug, Info, Error, etc.), Strategy Pattern for different appenders (File, Console, Database).
Rate Limiter Implementation of algorithms like Token Bucket or Sliding Window Log/Counter.
Focus on thread-safe data structures and handling concurrent requests.
Card Game (e.g., Deck of Cards, Poker) Classes for Card, Suit, Rank, Deck. Use Builder Pattern for deck creation. Focus on shuffling logic.
Splitwise / Expense Tracker Strategy Pattern for different splitting methods (equal, unequal, percentage), a graph-based model for simplifying settlements.
File System / Directory Composite Pattern to treat files and directories uniformly as nodes in a tree structure.
Classes for File, Directory, Permission.
🏛️ Category 1: Real-World Business Systems
These questions require you to define complex relationships, handle real-time updates, and manage concurrency. You should sketch a UML Class Diagram to guide the discussion.
System to Design, Key Classes & LLD Concerns ,Principal Engineer Differentiator
Movie Ticket Booking (BookMyShow), "Movie, Show, CinemaHall, Seat, Booking.", "Concurrency Control: Detailed mechanism (e.g., pessimistic locking on Seat rows,
optimistic locking with versioning) for concurrent bookings. Design Pattern:
Use Command Pattern for complex transaction chains (select seat → hold → pay)."
Ride-Sharing Service (Uber/Lyft), "Driver, Rider, Trip, MatchingStrategy.", "OCP/Strategy: Design the MatchingStrategy interface with concrete classes
(e.g., DistanceMatch, SurgePricingMatch) to be easily swapped. Observer:
Driver/Rider location updates using the Observer Pattern."
Splitwise/Expense Tracker, "User, Group, Expense, SplitStrategy.", "Advanced Algorithm: Implementation detail for simplifying debts
(e.g., converting group debts into a minimal set of peer-to-peer
transfers using a graph structure). Open/Closed Principle (OCP):
How new split types (PercentageSplit, RatioSplit) extend the system
without modifying core classes."
Car Rental System (ZoomCar), "Vehicle, User, Store, Reservation.", "State Pattern: Apply the State Pattern to the Vehicle lifecycle (Available,
Booked, In-Maintenance, In-Trip).
ISP: Separate interfaces for AdminVehicleOps (maintenance) and
UserVehicleOps (booking)."
Digital Wallet / Payment Gateway, "Wallet, Transaction, PaymentProcessor.", Reliability & Audit: Design the Transaction class and workflow for
atomicity and auditability. Use Decorator Pattern to add features like
logging or security checks to the base PaymentProcessor.
⚙️ Category 2: Technical/Infrastructure Systems
These problems test your understanding of core computer science fundamentals and thread safety.
System to Design, Key Classes & LLD Concerns, Principal Engineer Differentiator
LRU Cache, "LRUCache, Node (Doubly Linked List).", "Concurrency: Detailed explanation of using a ReadWriteLock to ensure thread
safety while allowing concurrent reads and exclusive writes,
demonstrating high-concurrency design."
Rate Limiter, "RateLimiter, TokenBucket / SlidingWindow classes.", Strategy Pattern: Use the Strategy Pattern to easily switch between Token
Bucket and Sliding Window implementations. Atomic Operations: Discuss using
thread-safe primitives (like Java's AtomicInteger) to manage tokens or
counters atomically.
Logger / Logging Framework, "Logger, Appender interface, LogMessage.", "Chain of Responsibility: Detailed implementation of the Chain of
Responsibility Pattern for message severity levels (e.g., DEBUG → INFO → ERROR).
Performance: Discuss asynchronous logging (using a queue and a separate thread)
to ensure the application thread is not blocked."
Pub/Sub System (Basic), "Topic, Subscriber interface, Publisher.", Observer Pattern: Formal use of the Observer Pattern for notifying subscribers.
Thread Safety: How the list of subscribers on a Topic is managed safely
during concurrent subscribe/unsubscribe operations.
🎮 Category 3: Classic Game Systems
These are used to quickly assess your command of OOP, modeling, and specific patterns.
System to Design, Key Classes & LLD Concerns, Principal Engineer Differentiator
Chess / Board Game, "Board, Piece (Abstract), Player, Move.", "Polymorphism (LSP): How the Piece.isValidMove() method handles all piece types
(Pawn, Rook, Knight, etc.) without violating LSP. Memento Pattern:
Design the Game and Move classes to support undo functionality using the Memento Pattern."
Elevator System, "Elevator, Floor, Request, Scheduler.", Concurrency/Threading: Detailed discussion of the Scheduler component and how it uses a
priority queue and worker threads to handle and dispatch concurrent Request objects.
Snake and Ladder, "Game, Board, Player, Cell (with Jump).", Custom Data Structures: Focus on how the Board (or Cell objects) manages the jumps
(snakes/ladders) for O(1) lookup.