Data Structures & AlgorithmsVery hardProduct company OA · Amazon/Microsoft-style OA

Worker i has the cost C[i][j] of doing job j, with C = [[9,2,7,8],[6,4,3,7],[5,8,1,8],[7,6,9,4]]. Each worker takes exactly one distinct job. Using DP over the set of jobs already assigned, what is the minimum total cost?

  1. A. 10
  2. B. 15
  3. C. 18
  4. D. 13

Correct answer: D. 13

Process workers in order; the state is the set of jobs taken, and the next worker index is its size. Giving each worker his own row minimum gives 10, but those minima can collide on the same job, so the feasible optimum is 13.

More Coding Interview Problems questions

Exams that ask this topic