Practice/Oracle/Leetcode 875. Koko Eating Bananas
CodingMust
You are given an array of integers tasks where each element represents the size of a task that needs to be processed, and an integer timeLimit representing the maximum number of hours available.
You can process tasks at any rate k (tasks per hour), where k is a positive integer. When processing a task of size s at rate k, it takes ceil(s / k) hours to complete (rounded up to the nearest integer).
Find the minimum rate k such that all tasks can be processed within the given timeLimit hours.
kk must not exceed timeLimitceil(task_size / k)tasks.length ≤ 10⁴tasks[i] ≤ 10⁹timeLimit ≤ 10⁹Example 1:
` Input: tasks = [3, 6, 7, 11], timeLimit = 8 Output: 4 Explanation:
Example 2:
` Input: tasks = [30], timeLimit = 10 Output: 3 Explanation:
Example 3:
Input: tasks = [1, 1, 1, 1, 1], timeLimit = 5 Output: 1 Explanation: At rate 1, each task takes exactly 1 hour, totaling 5 hours.