DEV Community

Cover image for Daily DSA and System Design Journal - 5
I.K
I.K

Posted on

Daily DSA and System Design Journal - 5

๐Ÿš€ 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
Enter fullscreen mode Exit fullscreen mode

โœจ 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)

Collapse
 
masterdevsabith profile image
Muhammed Sabith

Make a tutorial on greedy, it would be useful! I'm following you โค๏ธ๐Ÿ”ฅ

Collapse
 
ik_8a78062fd65be769dd835 profile image
I.K

down the line i'll see

and thank you for the follow . much appreciated

Collapse
 
parag_nandy_roy profile image
Parag Nandy Roy

Day 5 and youโ€™re already dropping system design gems...

Collapse
 
thedeepseeker profile image
Anna kowoski

Nice Article

Collapse
 
ik_8a78062fd65be769dd835 profile image
I.K

thank you very much