FastPrepWorkers Finishing One Job Together

Workers Finishing One Job Together

Jane Street logoJane Street● EasyNEW GRADFULLTIMEPHONE SCREEN

Updated

Problem statement

A team of workers shares one job, such as building a wall or painting a fence. Worker i would finish the whole job alone in minutes[i] minutes. Each worker always works at the same steady speed, and when they work together on the job their work simply adds up.

All workers start at the same moment and work on the same single job. Return the number of minutes they need to finish it together.

Answers within 1e-6 of the exact value are accepted.

Function

timeTogether(minutes: int[]) → double

Examples

Example 1

minutes = [60,30]return = 20.0

The first worker builds one wall per hour, so alone they need 60 minutes. The second builds two walls per hour, so alone they need 30 minutes. Per minute they finish 1/60 + 1/30 = 3/60 = 1/20 of the wall together, so the wall is done after 20 minutes.

Example 2

minutes = [4,12]return = 3.0

Per minute the two workers finish 1/4 + 1/12 = 4/12 = 1/3 of the job, so together they need 3 minutes.

Example 3

minutes = [2,3,6]return = 1.0

Per minute the three workers finish 1/2 + 1/3 + 1/6 = 1 whole job, so together they need 1 minute.

Constraints

  • 1 <= minutes.length <= 2 * 104
  • 1 <= minutes[i] <= 106

More Jane Street Phone Screen questions

Similar questions at other companies

Interview reports that mention this question

Jane Street interview experiences

All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public double timeTogether(int[] minutes) {
      // Write your code here.
    }
}
Checking account…