1057. Campus Bikes

In a logistics company, there are several warehouses and delivery trucks. Each warehouse has a specific location, and each truck has a designated parking spot. The Manhattan distance between a warehouse at (x1, y1) and a truck at (x2, y2) is |x1 - x2| + |y1 - y2|.

Assign trucks to warehouses using the following greedy rule. Consider every warehouse-truck pair, ordered by ascending Manhattan distance, then by ascending warehouse index, then by ascending truck index. Process the pairs in that order and assign the truck to the warehouse when both endpoints are still unassigned. Each warehouse receives exactly one truck and each truck is used by at most one warehouse. Return an array where element i is the index of the truck assigned to warehouse i.

This greedy rule is the problem's definition. It does not necessarily minimize the total distance of the assignment.

Examples
Input: [[[0,0],[2,1]],[[1,2],[3,3]]]
Output: [1,0]
Hints
Related Problems

1057. Campus Bikes

In a logistics company, there are several warehouses and delivery trucks. Each warehouse has a specific location, and each truck has a designated parking spot. The Manhattan distance between a warehouse at (x1, y1) and a truck at (x2, y2) is |x1 - x2| + |y1 - y2|.