Minimize the Largest Shard When Splitting Yahoo News Archive
Last updated: November 29, 2026
Quick Overview
Yahoo News articles must be split, in publication order, into at most k contiguous shards for reindexing. Given each article's size, return the smallest possible value for the largest shard's total size.
Yahoo
November 29, 20260
0
0 solved
Yahoo News articles must be split, in publication order, into at most k contiguous shards for reindexing. Given each article's size, return the smallest possible value for the largest shard's total size.
Search and content platform teams at Yahoo regularly rebalance archives across index shards while keeping time ranges contiguous. This tests binary search on the answer: spotting a monotone feasibility check and proving the bounds.
What the Interviewer Expects
- Identify the monotone predicate: if capacity C works, any larger capacity works
- Set bounds at max(size) and sum(sizes)
- Write a greedy feasibility check counting shards
- Explain O(n log S) complexity
- Mention 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 return the actual split points?
- What changes if shards must have at least m articles each?
- How would you handle floating-point sizes?
- How would you rebalance incrementally as new articles arrive?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: sizes in fixed order and k >= 1. Shards are contiguous and non-empty. Output: the minimum achievable maximum shard sum....
High-Level Design
Fix a capacity cap. Greedily fill a shard until adding the next article would exceed cap, then start a new one. This greedy uses the fewest shards for that cap, because delaying a cut never hurts....