← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Apr 2026

Summary

eBay SWE interview had me building out a full FileSystem class from scratch, pulling together a bunch of features that apparently built on each other across prior rounds. It was one of those design-heavy coding problems where the individual pieces aren't too bad but combining them cleanly under pressure is where things get messy.

Questions Asked (5)

Q1

Design and implement a FileSystem class that supports basic file operations: adding a file, getting its size, deleting it, and listing files sorted by size descending and name ascending.

Algorithms & Data StructuresSystem Design
Author's notes

The sorting requirement is where I slipped up initially.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a data structure that supports efficient add, get, delete, and sorted listing. Implement the FileSystem class with a hash map for O(1) file operations and maintain a sorted structure (e.g., balanced BST or sorted list) for listing, discussing trade-offs.

Pro tip: Mention that you would use a hash map for O(1) file operations and a balanced BST (like a TreeMap) to keep files sorted by size descending and name ascending, ensuring O(log n) insertions and deletions. This shows you understand the need for both fast lookups and efficient sorted retrieval.

1. Clarify Requirements

Ask about expected file sizes, number of files, concurrency needs, and whether file names are unique. Confirm the sorting order and any additional operations.

2. Design Data Structures

Propose using a hash map to store file names and sizes for O(1) add, get, and delete. For sorted listing, suggest a balanced BST (e.g., TreeMap) keyed by a composite of size (descending) and name (ascending).

3. Implement Core Operations

Write methods for addFile(name, size), getSize(name), deleteFile(name), and listFiles(). Ensure each operation updates both the hash map and the sorted structure consistently.

4. Analyze Complexity

State time and space complexity: O(1) for add, get, delete (amortized), O(log n) for insertion/deletion in sorted structure, and O(n) for listing. Space O(n).

5. Discuss Trade-offs and Extensions

Mention alternative approaches (e.g., sorted list with binary search, heap) and their trade-offs. Discuss handling concurrency, persistence, or additional operations like renaming.

Key Points to Mention

  • Use a hash map for O(1) average-case add, get, and delete operations.
  • Maintain a balanced BST (e.g., TreeMap) with a custom comparator for size descending and name ascending to support efficient sorted listing.
  • Ensure consistency between the hash map and the sorted structure during updates.
  • Analyze time complexity: O(1) for hash operations, O(log n) for BST operations, O(n) for listing.
  • Discuss trade-offs: e.g., using a sorted list gives O(n) insertion but O(1) listing if maintained, or a heap for partial sorting.
  • Consider edge cases: duplicate names, non-existent files, empty file system, and large numbers of files.

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

Q2

Extend the FileSystem to support searching for files by a given prefix and suffix.

Algorithms & Data Structures
Author's notes

Pretty mechanical once the file dict was in place.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the existing FileSystem design and the expected search semantics (e.g., case sensitivity, prefix/suffix matching). Then propose a data structure like a trie for prefix search and a reverse trie or suffix array for suffix search, or a combined index, and discuss time/space trade-offs. Finally, outline the implementation and test with edge cases.

Pro tip: Mention that you would first check if the FileSystem already has an index or if you need to build one, and consider whether the search should be case-sensitive or support wildcards. Also, discuss how to handle updates (file additions/deletions) efficiently.

1. Clarify requirements

Ask about the expected scale (number of files, query frequency), whether prefix and suffix are matched independently or combined, and if case sensitivity matters.

2. Choose data structures

Propose a trie for prefix search and a reverse trie for suffix search, or a single trie storing both forward and reversed strings. Discuss alternatives like suffix arrays or hash maps for specific cases.

3. Design the algorithm

Outline how to traverse the trie(s) to find all files matching the prefix and suffix, possibly intersecting the results if both are required.

4. Analyze complexity

State time complexity for insertion and search (e.g., O(L) for trie operations) and space complexity, and compare with naive approaches.

5. Handle edge cases and extensions

Discuss empty prefix/suffix, no matches, dynamic updates (insert/delete), and potential optimizations like caching frequent queries.

Key Points to Mention

  • Trie data structure for efficient prefix matching
  • Reverse trie or suffix tree for suffix matching
  • Time and space complexity trade-offs (e.g., O(L) search vs O(N) naive)
  • Handling dynamic file additions/deletions
  • Case sensitivity and exact matching semantics
  • Intersection of prefix and suffix results if both are required

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

Q3

Add user management to the FileSystem: support adding users with a storage capacity, letting users add files, and evicting the largest files first when a user exceeds their capacity.

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

This is where things got genuinely tricky.

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 tracks users, their storage capacity, and their files. Propose an efficient eviction strategy using a max-heap or balanced tree to identify the largest files, and discuss trade-offs between time and space complexity.

Pro tip: Mention that eviction should be triggered only when adding a file would exceed capacity, and consider whether to evict before or after adding the new file to avoid unnecessary evictions.

1. Clarify Requirements

Ask about expected scale, file size distribution, concurrency needs, and whether eviction should be immediate or batched. Confirm if users can have zero capacity or if files can be shared.

2. Design Data Model

Define classes for User (with capacity, used space, and a collection of files) and File (with size and metadata). Choose data structures that support efficient insertion, deletion, and retrieval of largest files.

3. Implement Eviction Logic

When a user adds a file that would exceed capacity, repeatedly remove the largest file(s) until there is enough space. Use a max-heap or balanced BST to track file sizes for O(log n) operations.

4. Analyze Trade-offs

Compare using a heap (fast eviction but slower deletion of arbitrary files) versus a balanced tree (supports both efficiently). Discuss time/space complexity and potential optimizations like lazy deletion.

5. Test and Edge Cases

Consider edge cases: file larger than capacity, multiple evictions, concurrent access, and persistence. Outline a testing strategy to validate correctness and performance.

Key Points to Mention

  • Use a max-heap or balanced binary search tree (e.g., TreeMap) to efficiently find and remove the largest files.
  • Eviction should occur only when necessary, and you must decide whether to evict before or after adding the new file.
  • Time complexity: adding a file O(log n) with heap, eviction O(k log n) where k is number of files evicted.
  • Space complexity: O(n) for storing files, plus overhead of the chosen data structure.
  • Consider concurrency: if multiple threads add files, use locks or concurrent data structures.
  • Discuss persistence: how to store user and file metadata across restarts (e.g., database, serialization).

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

Q4

Add a copyFile operation that duplicates a file while preserving both its size and its original owner.

System DesignTechnical Trade-offs
Author's notes

Sounded easy and mostly was.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what does 'copyFile' mean in this context (OS-level operation, API design, or system design)? Then outline a design that handles file duplication, size preservation, and owner preservation, discussing trade-offs such as permissions, atomicity, and performance. Finally, walk through the implementation steps and potential edge cases.

Pro tip: Demonstrate awareness of security and operational constraints: preserving ownership often requires elevated privileges, and copying large files can impact system performance, so consider asynchronous operations or chunking.

1. Clarify Requirements and Scope

Ask questions to understand the context: Is this a system call, a library function, or part of a larger system? What are the constraints (e.g., cross-platform, permissions, atomicity)?

2. Design the Operation

Outline the high-level steps: open source file, create destination file, copy data, set metadata (size and owner). Consider using system calls like copy_file_range or sendfile for efficiency.

3. Address Ownership Preservation

Explain how to preserve the original owner: retrieve the source file's UID/GID and apply them to the destination using chown. Note that this typically requires root privileges or CAP_CHOWN capability.

4. Handle Size Preservation and Data Integrity

Ensure the copied file has the same size by copying all bytes and verifying with stat. Discuss potential issues like sparse files and how to handle them.

5. Discuss Trade-offs and Edge Cases

Cover trade-offs: performance vs. atomicity, error handling (e.g., disk full, permission denied), and concurrency (e.g., source file modified during copy). Mention alternatives like reflink if supported.

Key Points to Mention

  • Use of system calls (e.g., copy_file_range, sendfile) for efficient data transfer
  • Preserving ownership requires appropriate privileges (root or CAP_CHOWN)
  • Handling metadata: size, timestamps, permissions, and ownership
  • Atomicity: using temporary file and rename to avoid partial copies
  • Error handling and rollback strategies
  • Performance considerations for large files (chunking, asynchronous I/O)

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

Q5

Implement compressFile and decompressFile operations with state tracking, ensuring that decompressing a file respects the user's current available capacity.

System DesignTechnical Trade-offsData Modeling
Author's notes

Compression was the most interesting piece.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, such as file size limits, compression algorithms, and capacity tracking granularity. Then design a stateful system that tracks available capacity and enforces it during decompression, while handling compression and decompression operations atomically. Finally, discuss trade-offs around consistency, concurrency, and failure recovery.

Pro tip: Emphasize idempotency and atomicity: ensure that decompression either fully succeeds or rolls back without consuming capacity, and that repeated operations don't corrupt state. This shows you think about real-world reliability.

1. Clarify Requirements and Constraints

Ask about file size limits, compression algorithms, capacity units, and whether operations are synchronous or asynchronous. Confirm if capacity is per-user or global and how it's updated.

2. Design State Model

Define a data model to track user capacity, file metadata, and operation status. Consider using a database with transactions or an in-memory store with persistence for state.

3. Implement Compression with State Tracking

Design compressFile to compress data, update metadata, and adjust capacity if needed (e.g., compressed size counts toward usage). Ensure atomic updates to avoid race conditions.

4. Implement Decompression with Capacity Check

Design decompressFile to first check if the decompressed size fits within available capacity. If not, reject the operation; if yes, decompress and update capacity atomically.

5. Address Trade-offs and Edge Cases

Discuss concurrency control (locks, optimistic concurrency), failure recovery (rollback on error), and scalability (sharding, caching). Mention how to handle partial failures and idempotency.

Key Points to Mention

  • Atomicity and consistency: use transactions or compare-and-swap to update capacity and file state together.
  • Capacity enforcement: check available space before decompression, and consider reserving space upfront to avoid race conditions.
  • Concurrency: handle multiple simultaneous compress/decompress requests with locking or optimistic concurrency control.
  • Failure handling: implement rollback or compensation logic if decompression fails midway, ensuring capacity is not leaked.
  • Idempotency: design operations so that retries don't double-count capacity or corrupt state.
  • Scalability: discuss partitioning by user, caching frequently accessed metadata, and using efficient compression algorithms.

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