Split Ordered Micro-Partitions Across Workers to Minimize Max Scan
Last updated: November 29, 2026
Quick Overview
Micro-partitions sit in clustering order with known byte sizes. Assign them to at most k workers in contiguous ranges (to keep locality) so the largest per-worker total is as small as possible, and return that value along with the ranges.
Snowflake
November 29, 20260
0
0 solved
Micro-partitions sit in clustering order with known byte sizes. Assign them to at most k workers in contiguous ranges (to keep locality) so the largest per-worker total is as small as possible, and return that value along with the ranges.
Snowflake distributes scan work across the nodes of a virtual warehouse, and keeping contiguous partition ranges preserves pruning and cache locality. This onsite question checks whether you see binary search on the answer with a greedy feasibility test, and whether you can reconstruct the actual assignment.
What the Interviewer Expects
- Identifies the search bounds: max single partition to total size
- Writes a greedy check that counts workers needed for a given cap
- Argues monotonicity: a larger cap never needs more workers
- Reconstructs ranges at the optimal cap
- Gives O(n log S) time
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 solve it with dynamic programming and when would that be preferable?
- What if workers have different speeds?
- How would you rebalance when a worker fails midway through its range?
- Why might you deliberately use fewer than k workers?
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: list of positive sizes in order and k >= 1. Output: the minimal possible maximum range sum and a list of (start, end) index ranges, at most k of them. Ranges must be contiguous and cover ever...
High-Level Design
The answer lies between max(sizes) (no range can be smaller than its largest partition) and sum(sizes) (one worker). For a candidate cap, a greedy pass packs partitions left to right and opens a n...