Maximum Units on a Truck

Easy · Greedy · about 10 minutes

Asked at Amazon, Google, Meta.

boxTypes[i] = [numberOfBoxes, unitsPerBox]. A truck can carry at most truckSize boxes. Return the maximum total number of units you can load.