Choosing the length of shorts

Write code · Medium · §8.3 Guessing the answer and checking it

videos holds the lengths (in seconds) of replay videos of live streams. You want to cut these videos into at least k short clips (shorts) that all have the same length. The length of a short is chosen in whole seconds, so it is a positive integer.

You can cut several shorts from one video, and the part left over is thrown away. You cannot join two videos to make one short. Some videos may give no shorts at all. Complete the function solution, which returns the greatest possible length of a short that still gives at least k shorts. If you cannot make k shorts even with a length of 1 second, return 0.

Function

solution(videos, k)

Constraints

Examples

videoskresult
[50, 70, 35]435
[10, 10, 3]82

Starter code

def solution(videos, k):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.