LeetCode Challenge: Capacity To Ship Packages Within D Days

🚀 Day 11/100 — LeetCode Challenge Solved Capacity To Ship Packages Within D Days The problem is not about finding an element… It’s about finding the minimum capacity that satisfies a condition. 💡 Approach: The answer lies between: 👉 max(weights) and sum(weights) 1) Apply binary search on this range 2) For each capacity, simulate shipping: -Count how many days it takes -If days ≤ given → try smaller capacity -Else → increase capacity 👉 This is a mix of binary search + greedy validation 🧠 Time Complexity: O(n log n) 💾 Space Complexity: O(1) 💡 What I learned: Whenever the problem asks for minimum/maximum value under a constraint, there’s a high chance it can be solved using binary search on answer. This pattern is getting clearer now. #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #Greedy #CodingJourney

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories