← Meta Interview Insights

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

Senior
Jun 2026

Summary

Meta SWE interview, got the cloud storage design question which goes pretty deep across four levels. Each level adds a new layer of complexity and the later ones have some real gotchas if you're not thinking carefully about state.

Questions Asked (4)

Q1

Design a basic cloud storage system with add_file, get_file_size, and delete_file operations.

System DesignAlgorithms & Data Structures
Author's notes

Pretty straightforward as a warmup.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (file size limits, concurrency, persistence) and then design a simple in-memory key-value store mapping file IDs to metadata (size, content pointer). Discuss trade-offs of different storage backends (in-memory vs. disk) and how to handle operations efficiently.

Pro tip: Mention that you'd use a hash map for O(1) operations and discuss how you'd extend it to a distributed system with sharding and replication, showing you think beyond the basics.

1. Clarify Requirements

Ask about expected scale, file size limits, concurrency needs, and persistence requirements to scope the design appropriately.

2. Define Data Model

Propose a File object with id, size, and storage location, and a mapping from file ID to File object.

3. Design Core Operations

Implement add_file (store metadata and content), get_file_size (return size from metadata), and delete_file (remove metadata and content).

4. Address Scalability and Reliability

Discuss how to handle large files, concurrency (locking), and persistence (write to disk or use a database).

5. Discuss Trade-offs and Extensions

Compare in-memory vs. disk-based storage, and mention potential extensions like versioning, deduplication, or distributed storage.

Key Points to Mention

  • Use a hash map for O(1) average time complexity for add, get, and delete operations.
  • Store file metadata separately from file content to optimize size queries.
  • Consider concurrency control (e.g., locks) for thread-safe operations.
  • Discuss persistence options: in-memory (fast but volatile) vs. disk-based (durable but slower).
  • Mention scalability: sharding by file ID, replication for fault tolerance.
  • Handle edge cases: duplicate file IDs, non-existent files, large file sizes.

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

Q2

Extend the storage system to support a get_n_largest operation that returns the N largest files filtered by a given name prefix, sorted by size descending and then by name ascending on ties.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The sorting criteria is the thing to nail down explicitly before coding.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify requirements first: whether the storage system is in-memory or disk-based, expected N, prefix filtering semantics, and update frequency. Then propose a data structure that supports efficient prefix filtering and top-N retrieval, such as a trie augmented with heaps or a balanced BST keyed by (name, size), and analyze trade-offs between query time, update time, and memory.

Pro tip: Mention that you would first check if the system already maintains a sorted index or if you need to build one; also discuss how to handle ties and whether the prefix filter should be case-sensitive, showing attention to edge cases.

1. Clarify requirements and constraints

Ask about data size, update frequency, expected N, prefix matching rules (case sensitivity, exact prefix vs. substring), and whether the result must be exact or approximate.

2. Choose data structures

Propose a trie for prefix filtering combined with a max-heap or sorted list per node, or a balanced BST keyed by (name, size) to support range queries and ordered retrieval.

3. Design the algorithm

Outline steps: traverse trie to prefix node, collect all files under that subtree, then use a min-heap of size N to find the N largest by size, with tie-breaking by name ascending.

4. Analyze complexity and trade-offs

Discuss time complexity for query (O(P + K log N) where P is prefix length, K is number of matching files) and update (O(L) for trie insertion), and compare with alternatives like scanning all files.

5. Address edge cases and optimizations

Handle empty prefix, N larger than matching files, ties in size, and concurrent updates; suggest caching frequent queries or maintaining a global sorted structure if updates are infrequent.

Key Points to Mention

  • Use of a trie or prefix tree to efficiently filter files by name prefix.
  • Min-heap of size N to find top N largest without sorting all matching files.
  • Tie-breaking logic: when sizes are equal, sort by name ascending.
  • Time and space complexity analysis for both query and update operations.
  • Trade-offs between different data structures (e.g., trie + heap vs. balanced BST vs. sorted array).
  • Handling of edge cases such as empty prefix, N > number of matches, and concurrent modifications.

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

Q3

Add user accounts to the storage system. Each user has a storage capacity limit. Implement add_user, add_file_by (which fails if the upload would exceed the user's capacity), and merge_user (which combines two users, summing their capacities and transferring all files to one user).

System DesignData ModelingTechnical Trade-offs
Author's notes

The back-pointer thing is what trips people up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then design a data model that efficiently supports user capacity limits and file ownership. Implement the operations with careful attention to edge cases like capacity overflow and merging users with existing files, and discuss trade-offs between different data structures and algorithms.

Pro tip: Demonstrate awareness of real-world concerns by mentioning concurrency control and transactional integrity, especially for merge_user which must atomically combine users and transfer files without data loss.

1. Clarify Requirements and Constraints

Ask about expected scale, whether users can have zero capacity, if files have sizes, and if merge_user should handle cases where combined files exceed new capacity. Confirm if operations need to be thread-safe.

2. Design Data Model

Propose a User class with capacity and used space, and a File class with size and owner reference. Consider using a hash map for user lookup and a list or set for files per user.

3. Implement add_user and add_file_by

For add_user, initialize capacity and zero used space. For add_file_by, check if user exists, if file size plus used space exceeds capacity, and if so, fail; otherwise, add file and update used space.

4. Implement merge_user

Combine two users by summing capacities and transferring all files from one to the other. Update used space accordingly. Decide which user to keep (e.g., the one with larger capacity or by ID) and remove the other.

5. Discuss Trade-offs and Edge Cases

Talk about time complexity, potential for fragmentation, and how to handle failures during merge. Mention alternative designs like using a database with transactions.

Key Points to Mention

  • Capacity enforcement: ensure add_file_by checks against remaining capacity and fails gracefully.
  • Data consistency: merge_user must atomically update both users and file ownership to avoid orphaned files.
  • Scalability: consider how the design scales with many users and files, and whether to use indexes or sharding.
  • Concurrency: if multiple operations can occur simultaneously, use locks or transactions to prevent race conditions.
  • Error handling: define clear error responses for non-existent users, capacity exceeded, or invalid merges.
  • Trade-offs: compare in-memory vs. persistent storage, and the impact on performance and reliability.

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

Q4

Add backup and restore functionality for users. Each user can have at most one backup snapshot. Restoring a user overwrites their current state entirely. How do you handle filename conflicts when restoring if another user has since claimed one of the backed-up filenames?

System DesignTechnical Trade-offsAdaptability & Ambiguity
Author's notes

This one actually got me.

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 handles conflicts by either renaming or rejecting the restore. Discuss trade-offs between consistency, user experience, and implementation complexity, and suggest a preferred approach with justification.

Pro tip: Show awareness that this is a classic conflict resolution problem; mention that the best solution depends on product priorities (e.g., data integrity vs. user convenience) and that you'd validate assumptions with stakeholders.

1. Clarify Requirements and Constraints

Ask questions to understand the system: Are filenames globally unique? Can users share filenames? What are the consistency requirements? Is the restore atomic? This ensures you address the right problem.

2. Identify Conflict Scenarios

Enumerate cases: the restoring user's backup contains a filename that now belongs to another user. Consider if the other user's file is active or also backed up, and whether the conflict is detected at restore time.

3. Propose Conflict Resolution Strategies

Present options: (a) reject the restore and notify the user, (b) rename the conflicting file (e.g., append a suffix), (c) merge or skip the file, or (d) allow overwrite with warning. Discuss pros and cons of each.

4. Recommend a Solution with Trade-offs

Choose a strategy based on likely product goals. For example, prioritize data integrity by rejecting the restore, or prioritize user convenience by renaming. Explain how it handles edge cases and maintains system consistency.

5. Discuss Implementation and Scalability

Outline how to implement the chosen approach: e.g., use a transaction to check for conflicts and apply changes atomically. Mention indexing, locking, or versioning to handle concurrency at scale.

Key Points to Mention

  • Global uniqueness of filenames and whether it's enforced by the system.
  • Atomicity of the restore operation to avoid partial states.
  • User experience: how to notify the user of conflicts and possible resolutions.
  • Trade-offs between data integrity (rejecting restore) and user convenience (renaming).
  • Concurrency control: handling simultaneous restores or file creations.
  • Scalability: efficient conflict detection with large numbers of users and files.

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