Daily DSA and System Design Journal – 12

🧠 Day 12 — Smallest Missing Integer & Schedule-Driven Jobs ⚙️

đź§© DSA Problems [1 hr]

Problem: 2598. Smallest Missing Non-negative Integer After Operations

đź’ˇ Approach: Greedy

Intuition

Each number in th…


This content originally appeared on DEV Community and was authored by I.K

🧠 Day 12 — Smallest Missing Integer & Schedule-Driven Jobs ⚙️

đź§© DSA Problems [1 hr]

Problem: 2598. Smallest Missing Non-negative Integer After Operations

đź’ˇ Approach: Greedy

Intuition

Each number in the array can be shifted by multiples of value.
That means all numbers that share the same remainder when divided by value belong to the same transformable group.

Example:
If value = 3, then numbers 0, 3, 6, 9 can all become one another through these operations.

We want to maximize the MEX (minimum excluded non-negative integer).
To do this, we iterate from 0 upward and check if there’s still a number left in the corresponding remainder group (mex % value).
If yes → use one and move forward.
If no → we found our MEX.

đź’» Code

class Solution:
    def findSmallestInteger(self, nums: List[int], value: int) -> int:
        mp = Counter(x % value for x in nums)
        mex = 0
        while mp[mex % value] > 0:
            mp[mex % value] -= 1
            mex += 1
        return mex

📊 Complexity

Metric Complexity
⏱ Time O(n)
đź’ľ Space O(value)

đź§© Key Learnings

  • Grouping by modular equivalence can simplify complex transformation logic.
  • Greedy strategies work beautifully when you can define a clear incremental choice.
  • “Remainders as buckets” is a powerful way to partition search spaces efficiently.

🏗 System Design — Roadmap.sh [1 hr]

⏰ Schedule-Driven Background Jobs

Not every task needs an event or user trigger — some just need to run on time.
That’s where schedule-driven jobs come in: systems that operate on timers, intervals, or cron schedules.

đź’ˇ What It Is

A schedule-driven job runs automatically based on time-based triggers such as:

  • Every minute/hour/day (cron, Celery Beat, Airflow DAGs, etc.)
  • At specific times (00:00 UTC daily backup)
  • After delays (run job after 5 minutes)

đź§± Common Examples

Type Description
đź§ľ Batch Processing Aggregate logs, update indexes, or recompute recommendations daily.
📊 Reports & Analytics Generate daily KPIs or email summaries every morning.
đź§ą Maintenance Tasks Cleanup old data, archive inactive sessions, or delete expired tokens.
đź§® Consistency Checks Verify data integrity or sync caches periodically.

⚙️ How It’s Done

  1. Local Scheduler: OS-based (like cron jobs or Windows Task Scheduler).
  2. App Scheduler: Framework-level (Celery Beat, Sidekiq Scheduler, or Quartz).
  3. External Scheduler: Managed cloud services (AWS EventBridge, Azure Logic Apps, Google Cloud Scheduler).

⚠️ Design Considerations

Concern Description
🧩 Idempotence A job might run twice — make sure repeating it doesn’t cause data corruption.
đź§Ť Single Instance Execution When your system scales, you must ensure only one instance of the job runs globally.
⏳ Overlapping Jobs A job may still be running when the next scheduled run starts — use locks or queues to prevent overlap.

đź”— Great read: What Does Idempotent Mean? (Particular.net)

đź§  Reflection

This day connects two powerful ideas:

  • In DSA, you optimized resource use by smartly grouping operations.
  • In System Design, you optimized time and execution with predictable schedules.

Both require discipline, rhythm, and state awareness — hallmarks of scalable design, both in code and in life.

âś… Day 12 Summary:

Consistency breeds reliability — in arrays, systems, and habits.


This content originally appeared on DEV Community and was authored by I.K


Print Share Comment Cite Upload Translate Updates
APA

I.K | Sciencx (2025-10-27T21:22:46+00:00) Daily DSA and System Design Journal – 12. Retrieved from https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/

MLA
" » Daily DSA and System Design Journal – 12." I.K | Sciencx - Monday October 27, 2025, https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/
HARVARD
I.K | Sciencx Monday October 27, 2025 » Daily DSA and System Design Journal – 12., viewed ,<https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/>
VANCOUVER
I.K | Sciencx - » Daily DSA and System Design Journal – 12. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/
CHICAGO
" » Daily DSA and System Design Journal – 12." I.K | Sciencx - Accessed . https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/
IEEE
" » Daily DSA and System Design Journal – 12." I.K | Sciencx [Online]. Available: https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/. [Accessed: ]
rf:citation
» Daily DSA and System Design Journal – 12 | I.K | Sciencx | https://www.scien.cx/2025/10/27/daily-dsa-and-system-design-journal-12/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.