On a campus represented by a n workers and m bikes, where
You are given an array workers of length n where workers[i] = [x_i, y_i] represents the position of the bikes of length m where bikes[j] = [x_j, y_j] represents the position of the
Each worker must be assigned exactly one bike, and each bike can be assigned to at most one worker. The assignments are made greedily according to the following priority rules:
Pairs of (worker, bike) with a smaller Manhattan distance are assigned first. The Manhattan distance between worker i and bike j is
If multiple pairs share the same distance, priority is given to the pair with the smaller worker index.
If multiple pairs share the same distance and worker index, priority is given to the pair with the smaller bike index.
Once a worker is assigned a bike or a bike is taken by a worker, neither can be part of any future assignment.
Return an array result of length n, where result[i] is the
Constraints:
n == workers.length
m == bikes.length
n m
workers[i].length == bikes[j].length ==
All worker and bike locations are unique.
On a campus represented by a n workers and m bikes, where
You are given an array workers of length n where workers[i] = [x_i, y_i] represents the position of the bikes of length m where bikes[j] = [x_j, y_j] represents the position of the
Each worker must be assigned exactly one bike, and each bike can be assigned to at most one worker. The assignments are made greedily according to the following priority rules:
Pairs of (worker, bike) with a smaller Manhattan distance are assigned first. The Manhattan distance between worker i and bike j is
If multiple pairs share the same distance, priority is given to the pair with the smaller worker index.
If multiple pairs share the same distance and worker index, priority is given to the pair with the smaller bike index.
Once a worker is assigned a bike or a bike is taken by a worker, neither can be part of any future assignment.
Return an array result of length n, where result[i] is the
Constraints:
n == workers.length
m == bikes.length
n m
workers[i].length == bikes[j].length ==
All worker and bike locations are unique.