Amazon·Software Engineer·Online Assessment (OA)
- Given an array of product sizes (with possible duplicates) and a corresponding cost array where cost[i] is the price to increment size[i] by 1, find the minimum total cost to make all sizes unique.
“My first instinct was to sort by size and greedily resolve conflicts left to right, but the cost array complicates things because you want to increment the cheaper item, not just the one that comes later.”