Tap here to switch tabs
Problem
Submissions

Problem: Maximum Units on a Truck

med
30 min
Try to solve the Maximum Units on a Truck problem.

Statement

You are given a list boxTypes, where each element boxTypes[i] is a pair [numberOfBoxes_i, numberOfUnitsPerBox_i] describing a box type. You are also given an integer truckSize, representing the maximum number of boxes the truck can carry in total.

Return the maximum total number of units that can be loaded onto the truck by choosing at most truckSize boxes across all types.

Note: You may take any number of boxes from a type, up to numberOfBoxes_i.

Constraints:

  • 1≤1 \leq boxTypes.length ≤1000\leq 1000

  • 1≤1 \leq numberOfBoxes_i, numberOfUnitsPerBox_i ≤1000\leq 1000

  • 1≤1 \leq truckSize ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Units on a Truck

med
30 min
Try to solve the Maximum Units on a Truck problem.

Statement

You are given a list boxTypes, where each element boxTypes[i] is a pair [numberOfBoxes_i, numberOfUnitsPerBox_i] describing a box type. You are also given an integer truckSize, representing the maximum number of boxes the truck can carry in total.

Return the maximum total number of units that can be loaded onto the truck by choosing at most truckSize boxes across all types.

Note: You may take any number of boxes from a type, up to numberOfBoxes_i.

Constraints:

  • 1≤1 \leq boxTypes.length ≤1000\leq 1000

  • 1≤1 \leq numberOfBoxes_i, numberOfUnitsPerBox_i ≤1000\leq 1000

  • 1≤1 \leq truckSize ≤106\leq 10^6