Minimum Upload Capacity
Backup files must be uploaded in the given order. Each hour you upload a contiguous batch of the next files whose total size is at most the link capacity C; a file is never split.
Return the smallest integer capacity C that uploads every file within hours hours.
Example 1
Input: sizes = [4, 8, 2, 5, 1], hours = 2 Output: 12 Explanation: Batches [4, 8] and [2, 5, 1]. With capacity 11 three hours are needed.
Example 2
Input: sizes = [5, 5, 5], hours = 1 Output: 15
Constraints
- 1 <= sizes.length <= 5 * 10^4
- 1 <= sizes[i] <= 1000
- 1 <= hours <= sizes.length
Hint 1
For a fixed capacity, a greedy pass tells you how many hours are needed.
Hint 2
More capacity never needs more hours, so binary search the capacity between max(sizes) and sum(sizes).
Good practice for: DevOps Engineer, Site Reliability Engineer, Cloud Engineer, Backend Developer, MLOps Engineer, Data Engineer
Run checks your code on 2 sample tests. Submit runs all 8 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.