Implement Optimal Bucket Batching | Amazon Coding Question