Databricks·Software Engineer·Onsite - Coding / Algorithms
- Given k disjoint groups of node IDs where each group is already internally connected, return exactly k-1 edges that connect all groups into one component. The catch: the result must be sampled uniformly at random over all valid minimal connecting edge sets, and you need to explain why naive approaches fail to achieve uniformity.
- On a 2D grid with start, destination, obstacles, and cells labeled by transportation mode (walk, bike, car, train), each mode has a per-step cost and time. You must pick one mode for the entire trip and can only traverse cells of that mode type. Return the mode with minimum total travel time, breaking ties by cost.
- Extend the grid problem to allow switching transportation modes mid-route, where each switch incurs a penalty. Find the optimal path minimizing total time then total cost.
- Further extend the problem to cap the number of allowed mode switches. Find the optimal route under the same objective while staying within the switch limit.
“I got the basic structure fast, pick a spanning tree over the groups and for each tree edge pick one node from each endpoint group.”