Maximum Units on a Truck

You are given some boxes to load onto one truck. The boxes are represented as a 2D array where each element is an array consisting of the number of boxes of that type and the number of units each box contains. Additionally, you are provided with an integer representing the maximum number of boxes the truck can carry. Your task is to find the maximum number of units that can be loaded onto the truck within the box limit.

Constraints

  • 1 <= boxTypes.length <= 1000
  • 1 <= numberOfBoxes_i, numberOfUnitsPerBox_i <= 1000
  • 1 <= truckSize <= 10^6
Saving… · 2 lines
class Solution:
def maximumUnitsOnTruck(self, boxTypes: List[List[int]], truckSize: int) -> int:
Console

Click Run to execute sample tests.