PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/System Design/Meta

Schedule and cancel delayed payments

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's system-design competency in building an in-memory scheduled-payments service, testing data modeling with maps-based pending stores, chronological execution ordering, cancellation semantics, race-safe concurrency, idempotency, and integration with a Top-N spenders aggregator.

  • medium
  • Meta
  • System Design
  • Software Engineer

Schedule and cancel delayed payments

Company: Meta

Role: Software Engineer

Category: System Design

Difficulty: medium

Interview Round: Take-home Project

Extend the system with scheduled payments that execute after a delay. Define: String schedulePayment(long timestamp, String sourceAccountId, String targetAccountId, int amount, long delay); boolean cancelScheduledPayment(long timestamp, String accountId, String scheduleId). Scheduled payments must execute in chronological order; when a payment executes, output or return a string summary of the execution sequence (e.g., concatenating "{accountId}{amount}" in execution order). Use maps (not lists) to manage pending items for efficient lookup/cancel. Specify when funds are reserved (schedule time vs. execution time), how failures/insufficient funds are handled, idempotency of cancels, and how executions update the top-N spenders feature.

Quick Answer: This question evaluates a candidate's system-design competency in building an in-memory scheduled-payments service, testing data modeling with maps-based pending stores, chronological execution ordering, cancellation semantics, race-safe concurrency, idempotency, and integration with a Top-N spenders aggregator.

Related Interview Questions

  • Design Top-K, Crawler, and Chess Systems - Meta (hard)
  • Design Search And Web Crawling Systems - Meta (medium)
  • Design an Instagram-Style Social Feed - Meta (medium)
  • Design an Online Game Leaderboard - Meta (hard)
  • Design an On-Demand Delivery Platform - Meta (medium)
Meta logo
Meta
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
System Design
6
0

Scheduled Payments Extension — Chronological Execution, Maps-Based Pending Store, and Top-N Spenders

Context

You are extending an existing in-memory payment system that already supports immediate transfers between accounts and maintains a "Top-N spenders" feature. Add support for scheduled payments that execute after a delay and must run in chronological order. Operations must be efficient for lookup/cancellation and correct under concurrent execution.

Assume the system tracks accounts by ID, balances as integers (smallest currency unit), and has an existing immediate transfer function that updates balances and the Top-N spenders aggregator.

New APIs to Implement

  1. String schedulePayment(long timestamp, String sourceAccountId, String targetAccountId, int amount, long delay)
    • Returns a unique scheduleId for the scheduled payment.
    • The payment should be scheduled to execute at executeAt = timestamp + delay.
  2. boolean cancelScheduledPayment(long timestamp, String accountId, String scheduleId)
    • Cancels a previously scheduled payment if it is still pending.
    • Returns true only if this call transitions the payment from pending to canceled; false otherwise (idempotent).
  3. Add a runner entry point to execute due items and return the execution summary string in chronological order:
    • String processDuePayments(long now)
    • Executes all pending payments with executeAt <= now, in chronological order. The return value is a concatenation of "{accountId}{amount}" for each successful execution in the order they were applied.

Requirements

  • Execution order:
    • Strictly ascending by executeAt.
    • For ties (same executeAt), break ties deterministically (e.g., by schedule time, then scheduleId lexicographically).
  • Data structures:
    • Use maps (not lists) to manage pending items for efficient O(1) lookup/cancel.
    • You may use ordered map variants (e.g., a tree/navigable map) to maintain chronological execution.
  • Funds reservation:
    • Explicitly state whether funds are reserved at schedule time or at execution time, and describe implications.
  • Failures/insufficient funds:
    • Define behavior when the source account has insufficient funds at execution (e.g., skip and mark failed, no retries), and how it impacts the summary string.
  • Cancel idempotency:
    • Define precise return semantics for repeated cancels, cancel-after-execution, and cancel of unknown IDs.
  • Top-N spenders:
    • Specify exactly when and how scheduled payment executions update the existing Top-N spenders feature.
  • Concurrency and idempotency:
    • Ensure a payment executes at most once; cancels and executions must be race-safe.

Output/Logging

  • When processDuePayments(now) executes due payments, return a string summarizing the successful executions by concatenating "{sourceAccountId}{amount}" in the exact execution order.
  • You may omit failed or canceled items from the summary.

Deliverables

  • Describe the in-memory data model and algorithms used to:
    • Schedule, cancel, and execute payments.
    • Maintain chronological order using maps.
    • Handle failures and idempotency.
    • Update Top-N spenders.
  • Provide a small illustrative example demonstrating the execution order and summary.

Solution

Show

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Meta•More Software Engineer•Meta Software Engineer•Meta System Design•Software Engineer System Design
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.