Number of Hours it Takes a Worker to Finish Job

You are given an integer representing the number of 'workers' and an array of integers representing the hours that a variety of tasks take as arguments. Return the minimum number of hours it will take for the workers to complete the tasks, if each worker can only complete one task at a time.

Requirements

  • Must return a single integer

Example #1

solve(2, [3, 2, 1])
> 3
  1. There are two workers and three tasks, one taking three hours, one taking two hours and one taking an hour
  2. Worker one can take the longest task of three hours
  3. Worker two can take the second task of two hours as well as the third task of one hour
  4. We return 3 The minimum number of hours it takes to finish the all of the tasks

Example #2

solve(2, [3, 2, 1, 1])
> 4
  1. There are two workers and four tasks, one taking three hours, one taking two hours and two taking an hour
  2. Worker one can take the longest task of three hours
  3. Worker two can take the second task of two hours as well as the third task of one hour
  4. Either of the two workers can take the final one hour job.
  5. We return 4 The minimum number of hours it takes to finish the all of the tasks