← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

eBay coding round that extended a file system design problem with compression features. Pretty focused on state tracking and edge cases.

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 core logic wasn't that hard but I fumbled the state tracking piece at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the existing file system design and the expected behavior of compressFile and decompressFile, including edge cases. Then, outline the implementation by adding a compressed flag and adjusting size, ensuring idempotency and proper return values. Finally, discuss trade-offs and potential optimizations.

Pro tip: Mention that you would add a 'compressed' boolean flag to the file object to track state, and ensure that compress/decompress operations are idempotent and return false appropriately. Also, consider thread-safety if the file system is concurrent.

1. Clarify Requirements and Assumptions

Ask clarifying questions about the file system's existing structure, how files are stored, and whether compression state is persistent. Confirm expected return values and edge cases.

2. Design Data Model Changes

Propose adding a boolean 'compressed' field to the file representation to track state. Ensure that the file size is updated accordingly (halved on compress, doubled on decompress).

3. Implement compressFile and decompressFile

Write methods that check file existence and current compression state, update size and flag, and return true/false as specified. Handle edge cases like already compressed/decompressed files.

4. Discuss Trade-offs and Extensions

Talk about trade-offs: e.g., storing original size vs. deriving it, thread-safety, and whether compression should be reversible if size is odd. Mention potential optimizations or alternative designs.

5. Test and Validate

Outline test cases: compressing a normal file, compressing an already compressed file, decompressing a compressed file, decompressing a normal file, and operations on non-existent files.

Key Points to Mention

  • Adding a 'compressed' boolean flag to track state
  • Updating file size correctly (halve on compress, double on decompress)
  • Returning false for non-existent files or invalid state transitions
  • Ensuring idempotency: repeated compress/decompress calls should not change state
  • Handling edge cases like odd file sizes (integer division) and potential precision loss
  • Considering thread-safety if the file system supports concurrent access

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