LeetCode 1011: Minimum Ship Capacity for Package Delivery

LeetCode 1011 — Capacity To Ship Packages Within D Days Worked on determining the minimum ship capacity required to transport all packages within a fixed number of days while preserving the given order. Approach — Binary Search on Capacity + Feasibility Check - Observed that ship capacity must lie between: - Maximum single package weight (lower bound) - Sum of all weights (upper bound) - Applied binary search within this capacity range - For each candidate capacity: - Simulated the shipping process day by day - Counted how many days were required without exceeding capacity - If shipping finished within the allowed days → tried a smaller capacity - Otherwise → increased the capacity This reduced the problem to O(n log(sum of weights)), a classic example of binary search on the answer space rather than the array itself. A strong reminder that many optimization problems are really about searching the minimum feasible value, not brute-forcing combinations. #leetcode #binarysearch #dsa #algorithms #codingjourney #problemsolving #javaprogramming #learninpublic #techskills #placements #codingpractice

  • text

To view or add a comment, sign in

Explore content categories