Deduplicate New File Versions With Content-Defined Chunking

Last updated: November 29, 2026

Quick Overview

Implement content-defined chunking with a rolling hash, then compute how many bytes must be uploaded to store a new file version when the previous version's chunks are already stored.

Box
Coding & Algorithms
Software Engineer
Box
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Implement content-defined chunking with a rolling hash, then compute how many bytes must be uploaded to store a new file version when the previous version's chunks are already stored.

Box keeps every version of a file and syncs large edited files through Box Drive, so storing and transferring only changed regions matters for cost and speed. A hard onsite round uses this to test rolling hashes, why fixed-size blocks fail on insertions, and careful boundary logic with min and max chunk sizes.

What the Interviewer Expects
  • Explains why fixed-size chunking breaks after a single inserted byte
  • Implements an O(n) rolling hash over a fixed window
  • Cuts chunks on a hash condition with min and max size guards
  • Dedupes by strong hash (SHA-256), not the rolling hash
  • Shows that an insertion only changes a few chunks
  • Discusses expected chunk size and metadata overhead
Key Topics to Cover
Rolling hash
Content-defined chunking
Deduplication
Hashing
Storage efficiency
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How do you pick the average chunk size, and what is the cost of going smaller?
  • Why reset the hash at each cut, and what happens if you do not?
  • How would you make chunking resistant to an attacker who probes which chunks you already store across tenants?
  • How would this fit into a resumable chunked upload API?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: old and new byte strings. Output: bytes that must be uploaded for new given all of old's chunks are stored. Chunks must be found by content so that inserting bytes near the start does not shift...

High-Level Design

Slide a polynomial hash over the last w bytes. Declare a boundary when h % avg == avg - 1 (probability 1/avg per byte, so expected chunk size is about avg) and the chunk is at least min_size, or for...


Submit Your Answer
Markdown supported

Related Questions