Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Minimum Cost to Hire K Workers
Bookmark
Brute Force
Sort + Heap
Input
Example 1
Example 2
Equal workers
Small k=2
Custom
quality
=
[10, 20, 5]
,
wage
=
[70, 50, 30]
,
k
=
2
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
teams tried
0
/ 3
minCost =
∞
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
teams tried
0
/ 3
minCost =
∞
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
10
team has
1
of 2
teams tried
1
/ 3
minCost =
210.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
10
20
rate
7.00
× quality
30
=
210.00
new minimum
teams tried
1
/ 3
minCost =
210.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
10
5
team has
2
of 2
teams tried
2
/ 3
minCost =
105.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
10
5
rate
7.00
× quality
15
=
105.00
new minimum
teams tried
2
/ 3
minCost =
105.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
20
team has
1
of 2
teams tried
3
/ 3
minCost =
105.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
20
5
rate
6.00
× quality
25
=
150.00
no better
teams tried
3
/ 3
minCost =
105.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
i
team
5
team has
1
of 2
teams tried
3
/ 3
minCost =
105.00
$70
10
7.00
0
$50
20
2.50
1
$30
5
6.00
2
best
10
5
Minimum cost = 105.00
algo
master
.
io
Step:
Start: Hire exactly 2 workers as cheaply as possible
0 / 11
Input
Example 1
Example 2
Equal workers
Small k=2
Custom
quality
=
[10, 20, 5]
,
wage
=
[70, 50, 30]
,
k
=
2
0 / 11
algo
master
.
io
Step:
Start: Hire exactly 2 workers as cheaply as possible