← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

eBay SWE interview focused on extending an in-memory file system across multiple rounds of added complexity. The final piece was an eviction policy on top of per-user storage, which is where things got interesting.

Questions Asked (1)

Q1

You're given an in-memory file system that already supports basic file operations, prefix/suffix search, and per-user storage quotas. Now add an updateCapacity(userId, newCapacity) method that evicts the user's files largest-first (ties broken alphabetically by name) until their total usage fits the new cap. Return the number of files evicted, or None if the user doesn't exist.

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

The base system was already built up over earlier parts of the problem, so by the time eviction came up I had some context.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose a data structure that efficiently supports eviction by size and name. Walk through the algorithm step-by-step, analyze time and space complexity, and discuss potential optimizations and trade-offs.

Pro tip: Mention that you would maintain a max-heap or balanced BST ordered by (size, name) for each user to achieve O(log n) eviction, and discuss how this integrates with existing prefix/suffix search and quota tracking.

1. Clarify requirements and constraints

Ask about expected file sizes, number of files per user, update frequency, and whether the eviction order must be strictly largest-first with alphabetical tie-breaking. Confirm return type and edge cases.

2. Design data structures

Propose maintaining per-user metadata: total usage, and a data structure that supports efficient retrieval of the largest file (e.g., max-heap keyed by (size, name) or a balanced BST). Ensure it integrates with existing operations.

3. Outline eviction algorithm

Describe the steps: check if user exists, compute excess = currentUsage - newCapacity, repeatedly extract the largest file (by size, then name) and remove it, updating usage and evicted count, until excess <= 0.

4. Analyze complexity and trade-offs

State time complexity: O(k log n) where k is number of evictions and n is number of files. Discuss alternatives like sorting all files (O(n log n)) and when each is preferable. Mention space overhead.

5. Discuss integration and edge cases

Explain how to update indexes for prefix/suffix search after eviction, handle concurrent updates, and deal with edge cases like newCapacity < 0, user with no files, or exact fit.

Key Points to Mention

  • Use a max-heap or balanced BST ordered by (size, name) for efficient largest-first eviction.
  • Maintain per-user total usage to quickly compute excess and avoid full scans.
  • Time complexity: O(k log n) for k evictions, better than sorting all files when k is small.
  • Update prefix/suffix search indexes (e.g., trie) after eviction to keep them consistent.
  • Handle edge cases: user not found (return None), newCapacity >= current usage (return 0), negative capacity.
  • Consider concurrency and thread-safety if the system supports concurrent operations.

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