Amazon·Software Engineer·Onsite - Coding / Algorithms
- Given K documents with various lengths and G GPUs, partition all documents into exactly G batches (one per GPU) to minimize total padding cost, where padding cost per batch is batch_size times the max length in that batch minus the sum of actual lengths. Output the minimum total padding cost and one valid batching.
“The key insight I kept second-guessing myself on was whether sorting first was actually valid.”