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?
- A. 10
- B. 15
- C. 18
- 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
- How many subsets of {1, 2, 3, ..., 12} have XOR equal to 0? The empty subset counts, because its XOR is 0.
- How many binary strings of length 10 contain no two adjacent 1s?
- In how many ways can a 3 x 4 grid be covered completely by non-overlapping 1 x 2 dominoes (each domino covers two adjacent cells, in…
- The universe {0, ..., 5} must be covered by a union of chosen sets from {0,1,2}, {2,3}, {3,4,5}, {0,4}, {1,5}. What is the minimum number…
- How many subsets (including the empty subset) of {1, 2, ..., 10} have a sum divisible by 3?
- From the values [3, 34, 4, 12, 5, 2, 19, 8], choose any subset (the empty subset allowed). What is the smallest possible value of |(sum of…