718. Cleaning Windows
A building has n floors, with the ith floor having windows[i-1] windows to clean. A worker has h hours to clean all windows.
Return the minimum number of windows he has to clean each hour to finish the job within the deadline. If his speed is k windows/hour and he is on a floor with less than k windows, he will clean those windows and not go to another floor till the hour is complete. If it cannot be completed return -1.
Example 1:
Input: windows = [5, 7, 1, 8], h = 8.
Output: 4
Explanation: For k = 3, time needed = 5/3 + 7/3 + 1/3 + 8/3 = 2 + 3 + 1 + 3 = 9
for k = 4, time needed = 5/4 + 7/4 + 1/4 + 8/4 = 2 + 2 + 1 + 2 = 7, thus 4 is the minimum speed needed.
Example 2:
Input: windows = [5, 7, 8, 9, 10], h = 4.
Output: -1
Explanation: The minimum time needed is 5.
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- n == number of floors
- 0 <= n <= 105
- 1 <= windows[i] <= 5000
- 1 <= h <= 5 * 105