← Meta Interview Insights

Meta·Software Engineer·Onsite - Coding / Algorithms·Senior

Senior
Jun 2026

Summary

Meta SWE interview covering the final level of a multi-part banking system design problem. The two functions were about merging accounts and querying historical balances, both of which had enough edge cases to keep things interesting.

Questions Asked (2)

Q1

Implement a merge_accounts function that folds one bank account into another: combine balances, combine outgoing transfer totals, move all pending scheduled payments from the source account to the destination, and delete the source. Return true on success, false if either account is missing or both IDs are the same.

System DesignAPI & IntegrationsData Modeling
Author's notes

The scheduled payments transfer was the part that tripped me up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and transaction requirements, then outline a step-by-step algorithm that validates inputs, performs the merge atomically, and handles edge cases. Emphasize correctness, idempotency, and failure recovery in your explanation.

Pro tip: Mention that the operation should be atomic and idempotent, and discuss how you would handle concurrent merges or partial failures to demonstrate production-level thinking.

1. Clarify Requirements and Data Model

Ask questions to understand the account structure, transfer totals, pending payments, and any constraints like transaction atomicity. Confirm the expected behavior for edge cases such as missing accounts or same IDs.

2. Outline Validation and Preconditions

Describe how to check that both accounts exist and that the source and destination IDs are different. Explain the return values for failure cases.

3. Design the Merge Algorithm

Detail the steps: combine balances, sum outgoing transfer totals, reassign pending scheduled payments, and delete the source account. Emphasize that these operations should be performed in a single transaction.

4. Address Edge Cases and Concurrency

Discuss handling of concurrent merges, idempotency, and rollback on failure. Mention potential race conditions and how to avoid them (e.g., locking).

5. Summarize and Verify

Recap the solution, confirm it meets all requirements, and suggest tests to validate correctness (e.g., unit tests for success and failure scenarios).

Key Points to Mention

  • Atomicity: ensure all operations succeed or fail together using a database transaction.
  • Idempotency: design the function so repeated calls with the same inputs don't cause unintended side effects.
  • Concurrency control: use locks or optimistic concurrency to prevent race conditions during simultaneous merges.
  • Data consistency: verify that balances and transfer totals are correctly combined and pending payments are reassigned without loss.
  • Error handling: return false for missing accounts or same IDs, and consider logging or alerting for unexpected failures.
  • Testing: outline unit tests for success, missing account, same ID, and concurrent merge scenarios.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Implement a get_balance function that returns an account's balance at a specific historical timestamp, not the current balance. Return null if the account didn't exist yet at that time.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

This one surprised me more than it should have.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the data model and requirements first, then propose an append-only transaction log with timestamped entries and a binary search for efficient historical queries. Discuss trade-offs between time and space, and consider edge cases like account creation time and multiple transactions at the same timestamp.

Pro tip: Mention that you would store the account creation timestamp separately to quickly determine if the account existed at the query time, and use a binary search on the sorted transaction log to find the balance at the given timestamp.

1. Clarify Requirements and Assumptions

Ask about the data model: how transactions are stored, whether timestamps are unique, and if the account balance can be derived from a transaction log. Confirm that the function should return null if the account didn't exist at the given timestamp.

2. Design Data Structure

Propose storing transactions in an append-only log sorted by timestamp, with each entry containing the timestamp, account ID, and amount (or balance delta). Also store the account creation timestamp separately for quick existence checks.

3. Algorithm for Balance Retrieval

Use binary search to find the latest transaction at or before the given timestamp. If no such transaction exists and the timestamp is before account creation, return null. Otherwise, compute the balance by summing deltas up to that point (or maintain a running balance if precomputed).

4. Handle Edge Cases and Optimizations

Consider multiple transactions at the same timestamp, negative balances, and large datasets. Discuss optimizations like caching or snapshotting for frequent queries, and trade-offs between query speed and storage overhead.

5. Analyze Complexity and Trade-offs

State the time complexity: O(log n) for binary search plus O(k) for summing k transactions, or O(log n) if using precomputed prefix sums. Discuss space-time trade-offs and scalability for a system like Meta.

Key Points to Mention

  • Append-only transaction log with timestamps for historical accuracy
  • Binary search to efficiently locate the relevant timestamp
  • Account creation timestamp to determine existence
  • Handling multiple transactions at the same timestamp (e.g., using sequence numbers)
  • Time and space complexity trade-offs (e.g., prefix sums vs. on-the-fly summation)
  • Scalability considerations for large-scale systems (sharding, caching, snapshots)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.