🧠 Before you code — what pattern fits?
costs[i] is the cost of hiring the i-th worker. Run k hiring sessions: in each, consider the first `candidates` workers and the last `candidates` workers still available, and hire the one with the lowest cost (lowest index on ties). Return the total cost to hire k workers.
(costs=[17,12,10,2,7,2,11,20,8], k=3, candidates=4) → 11
🎬 Video explanation · codestorywithMIK
Your solution runs against 2 unit tests, including edge and large-value cases.
Loading...
Test console · 2 unit tests
Submit your code to run it against all 2 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.