Problem 2462 · Medium

Total Cost to Hire K Workers

Keep a front pool and a back pool of candidates and always hire the cheaper candidate, using heaps.

Open the interactive visualisation