The Campus Bikes interview question is an assignment problem. You are given the coordinates of n workers and m bikes on a 2D plane (m >= n). You need to assign each worker a bike such that the overall assignment follows a "closest-first" priority based on Manhattan distance. If multiple (worker, bike) pairs have the same distance, the pair with the smaller worker index is preferred. If those are also equal, the one with the smaller bike index is preferred. This Campus Bikes coding problem is about stable sorting and greedy matching.
Google uses this to test a candidate's ability to handle custom sorting criteria and efficient data storage. Since the distances are integers and limited by the grid size, it tests if you can optimize the sorting using Bucket Sort or a Priority Queue. It’s a great exercise in processing large amounts of structured data with specific tie-breaking rules.
This follows the Array, Sorting, Heap (Priority Queue) interview pattern.
Worker 0: (0,0), Worker 1: (1,1). Bike 0: (0,1), Bike 1: (2,2).
Whenever you see a problem with many sorting criteria (distance, then index A, then index B), think about "Bucket Sort" if the primary value (distance) has a small range. It’s a powerful optimization that interviewers love to see.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Diagonal Traverse II | Medium | Solve | |
| Single-Threaded CPU | Medium | Solve | |
| Choose K Elements With Maximum Sum | Medium | Solve | |
| Find the K-Sum of an Array | Hard | Solve | |
| Relative Ranks | Easy | Solve |