← Meta Interview Insights

Meta·Software Engineer·Online Assessment (OA)·Senior

SeniorPrefer not to say
Apr 2026Remote

Summary

Meta coding screen, the kind with multiple levels that build on each other. Started manageable and got complicated fast once TTLs and timestamped reads entered the picture.

Questions Asked (3)

Q1

Design an in-memory key-field-value store that supports full history tracking per (key, field) pair, and implement a GET_AT_TIMESTAMP operation that returns the value visible at a given time.

Algorithms & Data StructuresSystem DesignData Modeling
Author's notes

The base store wasn't bad, I've done enough of these.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: operations (SET, GET, GET_AT_TIMESTAMP), timestamp semantics, and concurrency needs. Then propose a data model using a nested hash map (key -> field -> list of (timestamp, value) entries) and discuss how to efficiently implement GET_AT_TIMESTAMP via binary search. Finally, analyze time/space complexity and potential optimizations like versioned data structures or time-indexed storage.

Pro tip: Mention that timestamps can be monotonically increasing per key-field pair, allowing append-only logs and binary search; also discuss how to handle out-of-order writes or clock skew if timestamps are client-provided.

1. Clarify Requirements

Ask about expected operations (SET, GET, GET_AT_TIMESTAMP, DELETE), timestamp source (client vs server), and concurrency/consistency requirements. Confirm whether timestamps are unique per key-field and if out-of-order writes are possible.

2. Design Data Model

Propose a nested map: outer map keyed by key, inner map keyed by field, each field maps to a list of (timestamp, value) pairs sorted by timestamp. Alternatively, use a single map with composite key (key, field) to a version list.

3. Implement Operations

For SET, append (timestamp, value) to the list for the (key, field). For GET, return the latest value. For GET_AT_TIMESTAMP, binary search the list for the largest timestamp <= given timestamp and return its value (or null if none).

4. Analyze Complexity & Optimizations

Discuss time complexity: O(1) for SET (amortized), O(log n) for GET_AT_TIMESTAMP, O(1) for GET if latest cached. Space O(total versions). Suggest optimizations: pruning old versions if retention policy, using balanced BST or skip list for dynamic inserts, or time-bucketed storage.

5. Address Edge Cases & Concurrency

Handle missing key/field, timestamp before first version, and concurrent writes. Discuss locking (per key-field) or lock-free approaches with atomic appends, and how to ensure consistency during binary search.

Key Points to Mention

  • Use of nested hash maps for efficient key-field lookup
  • Storing version history as a sorted list of (timestamp, value) pairs
  • Binary search for GET_AT_TIMESTAMP to achieve O(log n) time
  • Handling out-of-order timestamps by sorting or using a balanced tree
  • Space-time trade-offs and potential pruning strategies
  • Concurrency control mechanisms (e.g., per-key locks, read-write locks)

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

Q2

Add COMPARE_AND_SET and COMPARE_AND_DELETE operations that only succeed if the current value matches the expected value provided by the caller.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

Straightforward once you've got the history layer working, but you have to be careful about what 'current' means.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the data structure and concurrency context, then design the operations to atomically check the expected value before mutating. Discuss implementation using locks or lock-free primitives like CAS, and analyze trade-offs in performance, correctness, and contention.

Pro tip: Emphasize atomicity and linearizability: these operations must appear instantaneous to other threads. Mention that COMPARE_AND_DELETE is not natively supported by hardware, so it requires a loop or lock, and discuss ABA problem mitigation.

1. Clarify requirements and context

Ask about the underlying data structure (e.g., hash map, list), concurrency model (threads, async), and expected performance. Confirm semantics: operations succeed only if current value equals expected, and what happens on failure (e.g., return false, throw exception).

2. Design atomic operations

For COMPARE_AND_SET, use a lock or CAS loop to atomically compare and update. For COMPARE_AND_DELETE, since no direct hardware primitive exists, use a lock or a CAS loop that marks the entry as deleted before removal.

3. Address concurrency challenges

Discuss ABA problem, memory reclamation (e.g., hazard pointers, RCU), and contention. Explain how to ensure linearizability and avoid race conditions.

4. Analyze trade-offs

Compare lock-based vs lock-free implementations: simplicity, scalability, and risk of deadlock/livelock. Discuss performance under high contention and potential optimizations like backoff.

5. Test and validate

Outline testing strategies: unit tests for correctness, stress tests with multiple threads, and model checking for linearizability. Mention tools like ThreadSanitizer or Jepsen.

Key Points to Mention

  • Atomicity and linearizability guarantees
  • Lock-based vs lock-free implementations (e.g., mutex vs CAS loop)
  • ABA problem and solutions (e.g., version counters, tagged pointers)
  • Memory reclamation and safe deletion (e.g., hazard pointers, epoch-based reclamation)
  • Performance implications: contention, scalability, and backoff strategies
  • Failure semantics: return values, exceptions, and idempotency

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

Q3

Extend the store to support per-record TTL with timestamped expiry, and ensure consistent semantics when TTL interacts with timestamped reads and compare-and-set operations.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This is where the whole thing gets gnarly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose a design that stores per-record TTL as an absolute expiry timestamp, and define consistent semantics for reads and CAS operations. Walk through how TTL interacts with timestamped reads and CAS, addressing edge cases like expired records and concurrent operations.

Pro tip: Emphasize that using absolute timestamps avoids clock skew issues and simplifies expiry checks; also highlight the importance of atomicity in CAS operations to prevent race conditions with TTL.

1. Clarify Requirements and Constraints

Ask questions to understand the expected scale, consistency requirements, and whether TTL is set at write time or can be updated. Confirm if timestamped reads and CAS are already supported and how they should interact with TTL.

2. Design Data Model

Propose storing each record with an absolute expiry timestamp (e.g., Unix epoch milliseconds) instead of a relative TTL. This ensures consistent expiry semantics regardless of when reads occur.

3. Define Read Semantics

Specify that timestamped reads should return the record only if the read timestamp is before the expiry timestamp. If the read timestamp is after expiry, the record is considered non-existent, even if not yet physically deleted.

4. Define CAS Semantics

For CAS operations, ensure that the operation fails if the record has expired at the time of the operation. The CAS should atomically check expiry and the expected value before applying the update.

5. Address Edge Cases and Implementation

Discuss handling of expired records (lazy deletion vs. background cleanup), clock synchronization, and atomicity guarantees. Mention potential performance implications and trade-offs.

Key Points to Mention

  • Use absolute expiry timestamps to avoid clock skew and simplify expiry checks.
  • Timestamped reads should treat records as expired if the read timestamp >= expiry timestamp.
  • CAS operations must atomically verify that the record has not expired and that the expected value matches.
  • Consider lazy deletion or background cleanup for expired records to reclaim space.
  • Ensure consistency across distributed nodes by relying on a synchronized clock or logical timestamps.
  • Discuss trade-offs between strict consistency and performance, e.g., using optimistic concurrency control.

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