DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Binary Search

Capacity to Ship Packages (Feasibility BS)

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Capacity to Ship Packages (Feasibility BS)** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Binary search on capacity; greedy feasibility check **Edge Cases to Consider:** - (1) k = n (one per day) - (2) k = 1 (all together) - (3) Single package

Examples

Example 1
Input: [1,2,3,4,5,6,7,8,9,10], 5
Output: 15
Explanation: Classic
Example 2
Input: [3,2,2,4,1,4], 3
Output: 6
Example 3
Input: [1,2,3,1,1], 4
Output: 3

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪k = n (one per day)
  • ▪k = 1 (all together)
  • ▪Single package
Frequently Asked At
AmazonGoogleMicrosoft