SYSTEM DESIGN
Day 19 – What is a queue?
What it is:
A waiting line for work to be done later.
Why it exists:
Systems can’t handle everything at once.
Tiny example:
Orders wait before being processed.
Mental note:
Queue = absorb spikes, smooth load.
SYSTEM DESIGN
Day 18 – What is a bottleneck?
What it is:
The slowest part of a system.
Why it exists:
Systems move at the speed of their weakest link.
Tiny example:
Fast app, slow database.
Mental note:
Optimize bottlenecks, not everything.
SYSTEM DESIGN
Day 17 – What is load?
What it is:
Amount of work hitting a system at the same time.
Why it exists:
Users don’t arrive one by one.
Tiny example:
Many people ordering food at 8 PM.
Mental note:
High load stresses weak system parts
Day 17
Stack vs queue
- a stack is a last in first out LIFO
- queue is a first in first out FIFO
- for ex if you take a box and places plates in order 1,2,...10 . And now the very first plate you take is 10
this is stack
- the exact opposite is queue
SYSTEM DESIGN
Day 16–What is throughput?
What it is
How much work a system finishes per unit time
Why it exists
Speed alone doesn’t tell capacity
Tiny example
Checkout system handling 1,000 orders per minute
Mental not
Latency=how fast one request is.Throughput=how many total
SYSTEM DESIGN
Day 15 – What is bandwidth?
What it is:
How much data can move at once.
Why it exists:
Links have limits, not infinite capacity.
Tiny example:
Slow video on weak internet.
Mental note:
Bandwidth = volume, not speed.
Day 16 – Change Representation When Stuck
Gym drill:
If direct thinking fails, change how data is represented.
Examples:
• values → differences
• numbers → frequencies
• indices → prefix sums
• operations → states
Day 15 – Think in “Constraints First”
Gym drill:
Before thinking of logic, read constraints only.
If N ≤ 100 → brute force possible
If N ≤ 2e5 → O(N log N) or O(N) only
If values ≤ 1e9 → watch overflow
If multiple queries → precomputation needed
Day 14 – Resetting how I learn CP Realization: Posting concepts without struggling on problems is useless. New rule: Problems first. Confusion first. Insight later. Goal: Each post should come from being stuck, not from theory. Mental note: Insight sticks only after friction
SYSTEM DESIGN
Day 13 –NETWORK
What it is:
A way for computers to connect and talk to each other
Why it exists:
One computer alone can’t serve everyone
Tiny example:
Your phone sends a message to a server over the internet
Mental note:
No network→no communication btw systems
Day 13 – endl vs '\n' (C++ I/O Trap)
Concept:
endl flushes output buffer every time.
Problem:
Frequent endl → slow I/O → TLE.
Fix:
Use '\n' instead.
It helps to reduce the time of the operation
SYSTEM DESIGN
Day 12 – Stateful system
What it is:
A system that keeps memory between requests.
Why it exists:
Some actions need context from the past.
Tiny example:
Shopping cart remembers added items.
Mental note:
Stateful = past affects the next step.
Day 11 – Custom Sort (Comparator)
Concept:
You can control how sorting happens.
Example:
sort(v.begin(), v.end(),
[](int a, int b){ return a > b; });
Use cases:
• Sort by second value in pair
• Custom order problems
• Greedy strategies
SYSTEM DESIGN
Day 11 Stateless system
What it is:
A system that remembers nothing between requests.
Why it exists:
No memory makes systems simpler and easier to scale
Tiny example:
Search page:every search is treated as new
Mental note:
Stateless=no past,only present request