Daily DSA and System Design Journal - 5

I

I.K

Guest

πŸš€ 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​


Code:
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 πŸš€.

Continue reading...
 


Join 𝕋𝕄𝕋 on Telegram
Channel PREVIEW:
Back
Top