Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Campus Bikes II
Bookmark
Backtracking
Top-Down DP
Bottom-Up DP
Input
Standard
Three Workers
Simple
Custom
workers
=
[[0,0],[2,1]]
,
bikes
=
[[1,2],[3,3]]
B0
B1
W0
W1
currDist = 0
minDist = -
B0
B1
W0
W1
currDist = 0
minDist = -
B0
B1
W0
W1
currDist = 0
minDist = -
worker 0 needs a bike
3
B0
B1
W0
W1
currDist = 3
minDist = -
distance 3, running total 3
3
B0
B1
W0
W1
currDist = 3
minDist = -
bike 0 is taken
3
3
B0
B1
W0
W1
currDist = 6
minDist = -
distance 3, running total 6
3
3
B0
B1
W0
W1
currDist = 6
minDist = 6
total = 6
B0
B1
W0
W1
currDist = 0
minDist = 6
bike 0 is free again
6
B0
B1
W0
W1
currDist = 6
minDist = 6
distance 6, running total 6
6
B0
B1
W0
W1
currDist = 6
minDist = 6
6 already reaches the best 6
B0
B1
W0
W1
currDist = 0
minDist = 6
minimum total distance = 6
algo
master
.
io
Step:
Give each of the 2 worker(s) a bike so the total Manhattan distance is smallest
0 / 18
Input
Standard
Three Workers
Simple
Custom
workers
=
[[0,0],[2,1]]
,
bikes
=
[[1,2],[3,3]]
0 / 18
algo
master
.
io
Step:
Give each of the 2 worker(s) a bike so the total Manhattan distance is smallest