Minimum Van Capacity to Ship All Parcels Within D Days
Last updated: November 29, 2026
Quick Overview
Parcels at a fulfillment center must leave in the given order, with one van trip per day carrying a contiguous batch. Return the minimum van capacity (in kg) that ships all parcels within D days.
Flipkart
November 29, 20260
0
0 solved
Parcels at a fulfillment center must leave in the given order, with one van trip per day carrying a contiguous batch. Return the minimum van capacity (in kg) that ships all parcels within D days.
A Flipkart screening favorite for testing 'binary search on the answer', set in a fulfillment center outbound dock. The interviewer looks for the monotonic feasibility argument and correct search bounds.
What the Interviewer Expects
- Recognize that feasibility is monotonic in capacity
- Pick bounds: max single parcel weight up to total weight
- Write a greedy O(n) feasibility check
- Use a lower bound style binary search without off by one errors
- State O(n log(sum)) 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
- What if parcels can be reordered freely?
- What if there are V vans per day instead of one?
- How would you also return the day each parcel ships?
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: parcel weights in fixed dispatch order, and
Ddays. - Each day ships one contiguous batch; a batch's weight must not exceed capacity.
- Output: smallest integer capacity that finishes withi...
High-Level Design
If capacity c works, any larger capacity also works, so the predicate feasible(c) is monotonic: false, false, ..., true, true. Binary search for the first true. The lower bound is the heaviest par...