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
Coding & Algorithms
Software Engineer
Flipkart
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
binary search on answer
greedy feasibility
monotonic predicate
partitioning
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
  • 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 Problems
Sample Answer
Requirements
  • Input: parcel weights in fixed dispatch order, and D days.
  • 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...


Submit Your Answer
Markdown supported