Smallest Shard Capacity to Store Boards in Creation Order
Last updated: November 29, 2026
Quick Overview
Boards must be assigned to storage shards in creation order, each shard holding a contiguous range of boards. Given each board's size and the number of shards, find the smallest shard capacity that makes this possible.
0
0
0 solved
Boards must be assigned to storage shards in creation order, each shard holding a contiguous range of boards. Given each board's size and the number of shards, find the smallest shard capacity that makes this possible.
Pinterest stores Pins and boards in sharded MySQL and similar stores where range-based layouts keep related data together. The question checks whether you spot the monotonic feasibility property and binary search on the answer instead of trying to enumerate splits.
What the Interviewer Expects
- Identifies that feasibility is monotonic in capacity
- Sets correct bounds: max single board to total size
- Implements a greedy feasibility check in O(n)
- Uses a lower-bound binary search loop without off-by-one errors
- Mentions the DP alternative and why it is slower
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you also return the split points?
- If boards can be reordered, how does the problem change?
- How would you rebalance when a single board grows larger than the current capacity?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Inputs: positive sizes in fixed order, shards >= 1.
- Use at most
shardsgroups (empty shards are fine). - Output: minimum possible largest group sum. Empty input returns 0....
High-Level Design
If capacity C works, any C' > C also works, so we binary search C in [max(size), sum(size)]. For a given C, greedily pack boards into the current shard until the next one would overflow, then open a n...