Minimum Cost to Hire K Workers
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
There are n workers; worker i has a quality quality[i] and a minimum wage expectation wage[i]. You must hire exactly k workers and pay each of them under two rules:
- Within the hired group, pay is proportional to quality: every hired worker earns the same amount per unit of quality.
- Every hired worker is paid at least their minimum wage expectation.
Return the minimum total amount of money needed to hire such a group, as a floating-point number. Answers within 10^-6 of the exact value are accepted.
Examples
Constraints
- n == quality.length == wage.length
- 1 <= k <= n <= 10^4
- 1 <= quality[i], wage[i] <= 10^4
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.