Schedule GPU Pods and Drain a Node
Company: Together
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
## Problem
Implement `schedule_gpu_nodes(nodes, request_gpus, delete_name)`.
Each node is `{name, gpus, running_pods}` and each pod is `{name, required_gpus}`. Inputs are well formed: pod names and node names are unique, and existing pods do not exceed node capacity.
Return two results:
1. `eligible`: every node with at least `request_gpus` free GPUs, represented as `[node_name, free_gpus]` in node input order.
2. `reschedule`: remove the node named `delete_name` and place all of its pods on the remaining nodes without moving existing pods. Return `[pod_name, destination_node]` pairs in the drained node's pod order. If no complete placement exists, return `null`. When several placements work, return the lexicographically smallest destination-node sequence.
## Constraints
- Up to 100 nodes for eligibility queries.
- The drained node has at most 12 pods and at most 12 remaining nodes for exact rescheduling.
- GPU counts are nonnegative integers.
- A pod must fit entirely on one node.
## Example
If node `A` has capacity 8 with pods using 6 GPUs, node `B` has capacity 8 with pods using 4 GPUs, and node `C` is empty with capacity 8, then a request for 2 GPUs lists all three nodes with free capacities `2`, `4`, and `8`. Draining `A` must place all of its pods on `B` and `C` or return `null`.
## Hint
Eligibility is direct accounting. Exact rescheduling is bin packing: sort or prioritize difficult pods for search, prune when remaining capacity is insufficient, and skip symmetric states while still honoring the required deterministic output.
## Interview Follow-ups
- Compare greedy, first-fit decreasing, backtracking, and branch-and-bound.
- Scale the rescheduler when an exact search is too expensive.
- Make scheduling safe under concurrent pod creation.
Quick Answer: Determine which GPU nodes can accept a request and whether every pod from a drained node can be reassigned without moving existing workloads. Preserve deterministic output while handling whole-pod capacity, exact-fit cases, infeasible placements, concurrent pod creation, and the scale trade-off between exact and approximate scheduling.