← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

eBay SWE interview that extended a file system design problem into compression territory. Pretty focused on state tracking and edge cases, not just the happy path.

Questions Asked (1)

Q1

Extend a file system implementation with compressFile(name) and decompressFile(name) methods. compressFile should halve the file's size and return false if the file doesn't exist or is already compressed. decompressFile should restore the original size and return false if the file doesn't exist or isn't currently compressed.

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

The size halving part was easy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the existing file system's data structures and how file sizes are stored. Then, design the methods to check preconditions (existence, compression state) before modifying size, ensuring idempotency and proper return values. Finally, discuss potential edge cases and trade-offs, such as handling concurrent access or large files.

Pro tip: Mention that you would store a boolean flag or use a sentinel value (e.g., negative size) to track compression state, and consider thread-safety if the file system is shared. This shows awareness of real-world constraints beyond the basic requirements.

1. Clarify Requirements and Assumptions

Ask about the file system's existing API, how file sizes are represented, and whether compression state is already tracked. Confirm expected behavior for edge cases like zero-size files or repeated calls.

2. Design Data Structure Changes

Determine if you need to add a compression flag to the file object or infer state from size. Consider using a separate set to track compressed files if modifying the file structure is not allowed.

3. Implement compressFile and decompressFile

Write pseudocode for both methods: check existence, check current compression state, update size (halve or double), and update compression flag. Return false if preconditions fail.

4. Handle Edge Cases and Error Conditions

Address cases like file not found, already compressed/decompressed, zero-size files, and potential integer overflow. Discuss how to handle concurrent access if needed.

5. Analyze Complexity and Trade-offs

State time and space complexity (O(1) for hash map lookups). Discuss trade-offs of storing compression state versus inferring it, and any impact on existing operations.

Key Points to Mention

  • Use a hash map for O(1) file lookup by name.
  • Track compression state with a boolean flag or by storing original size.
  • Ensure idempotency: repeated compress/decompress calls should not change size further.
  • Handle edge cases: non-existent files, already compressed/decompressed, zero-size files.
  • Consider thread-safety if the file system is accessed concurrently.
  • Discuss trade-offs: memory overhead of extra flag vs. inferring state from size.

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