๐ Day 5: System Design + DSA Journey
Hello, I'm continuing my journey of daily learning, focusing on System Design concepts (via the roadmap.sh System Design Roadmap) and then tackling DSA challenges on LeetCode. This is DAY 5!
๐ System Design: Consistency Patterns
Todayโs System Design concept explores Consistency Patterns โ the different ways distributed systems manage and present data. The core challenge here is balancing correctness, performance, and availability.
The three main consistency models are:
- Strong Consistency
- Weak Consistency
- Eventual Consistency
๐ Strong Consistency
After an update, any subsequent read immediately reflects the change.
- Data is replicated synchronously, ensuring every replica always has the latest value.
- Guarantees correctness, but at the cost of availability and often higher latency.
๐ Example: Financial systems (e.g., bank transfers).
When money moves from one account to another, all balances are updated everywhere instantly to prevent discrepancies. Accuracy is critical, even if responses are slower.
๐ Weak Consistency
After an update, subsequent reads may or may not reflect the latest value.
- Updates may not propagate immediately.
- Provides high availability and low latency, but risks temporary inconsistencies.
๐ Example: Online gaming platforms.
Player actions are visible instantly within the same data center, but lag or temporary connection drops can cause other players to see delayed or missing actions.
โณ Eventual Consistency
A form of weak consistency โ all updates will eventually propagate to all replicas.
- Replication is asynchronous.
- Prioritizes availability and speed but allows temporary inconsistencies.
๐ Example: Social media platforms.
When a user posts an update, it may appear instantly to nearby users but take time to reach users in other regions. Some see it immediately, others later โ but eventually, everyone converges to the same state.
๐ญ My Thoughts
Consistency patterns made me reflect on the trade-offs engineers face daily. Strong consistency feels safe but slows things down; eventual consistency feels fast and scalable but risks temporary โweirdness.โ
The art of system design lies in choosing the right consistency model for the right use case โ banking apps need precision, but social apps need speed.
๐ป DSA Challenge: Integer to Roman
Todayโs LeetCode problem was 12. Integer to Roman.
โณ Time spent: ~2+ hours (with some help from a reference solution).
This was a great exercise in mapping + greedy iteration.
๐ Understanding the Problem
Convert an integer (1 โค num โค 3999) into its Roman numeral representation.
Roman numerals are based on fixed symbol-value pairs:
- I (1), V (5), X (10), L (50), C (100), D (500), M (1000)
- Special cases: IV (4), IX (9), XL (40), XC (90), CD (400), CM (900)
๐งฉ My Approach: Dictionary + Loop
- Built a lookup dictionary for symbol-value pairs.
- Iterated over values in descending order.
- Subtracted and appended symbols until the number was reduced.
๐จโ๐ป Code Snippet
class Solution:
def intToRoman(self, num: int) -> str:
# Mapping integer values to Roman numerals
num_map = {
1: "I", 4: "IV", 5: "V", 9: "IX",
10: "X", 40: "XL", 50: "L", 90: "XC",
100: "C", 400: "CD", 500: "D", 900: "CM",
1000: "M"
}
result = ''
for n in [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]:
while num >= n:
result += num_map[n]
num -= n
return result
โจ Key Takeaways
- Greedy approach works beautifully: always take the largest possible Roman numeral first.
- Using a dictionary for mapping keeps the logic clean.
- Avoided over-complicating with list comprehensions โ simple loops made it easier to debug.
๐ Final Thoughts
Day 5 was all about patterns โ both in System Design (consistency patterns) and DSA (pattern-driven mapping with Roman numerals).
- On the System Design side โ I learned how different consistency guarantees directly impact user experience and system reliability.
- On the DSA side โ I reinforced the power of lookup tables + greedy iteration.
Five days in, I can feel the compounding effect of showing up daily. Each small lesson stacks into a bigger picture of becoming a stronger engineer ๐ช.
๐ค Letโs Connect!
๐ This marks Day 5 of my journey! Writing these daily reflections has been as valuable as solving the problems themselves.
If youโve been following along, Iโd love to hear from you:
- What consistency model have you worked with in distributed systems?
- Do you have a favorite trick for greedy algorithms like this one?
- Or just drop a ๐ if youโd like me to keep sharing these daily learnings!
Your engagement (comments, shares, or reactions) means the world ๐ โ it helps me refine, stay accountable, and reach more learners on the same path. Letโs make this journey collaborative ๐.
Top comments (5)
Make a tutorial on greedy, it would be useful! I'm following you โค๏ธ๐ฅ
down the line i'll see
and thank you for the follow . much appreciated
Day 5 and youโre already dropping system design gems...
Nice Article
thank you very much