FastPrepMaximum Units on a Truck
Problems/Maximum Units on a Truck

Maximum Units on a Truck

Roblox logoRoblox● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report calls Efficient Shipping similar to Maximum Units on a Truck and links that task. This version uses a capacity counted in boxes, with the number of boxes available and the units for each type. We chose the interfaces, the edge rules, and the limits. Our version is about 95% the same as the reported question.

There are boxes.length box types. Type i has boxes[i] available boxes, each containing unitsPerBox[i] units. Every box uses one truck slot, regardless of its unit count.

Load at most capacity boxes and return the maximum total units. You may take any integer number of boxes from each type up to its availability; you may leave slots unused. For this exercise, assume no other weight or volume limit, and do not change either input array.

Function

maximumTruckUnits(boxes: int[], unitsPerBox: int[], capacity: int) → int

Examples

Example 1

boxes = [1,2,3]unitsPerBox = [3,2,1]capacity = 4return = 8

Take one 3-unit box, two 2-unit boxes and one 1-unit box.

Example 2

boxes = [2,3]unitsPerBox = [4,4]capacity = 4return = 16

Any four available boxes have 4 units each.

Example 3

boxes = [2,1]unitsPerBox = [8,5]capacity = 0return = 0

No box fits when the truck has no slots.

Constraints

  • 0 <= boxes.length = unitsPerBox.length <= 1000.
  • 0 <= boxes[i], unitsPerBox[i] <= 1000.
  • 0 <= capacity <= 1000000.
  • The maximum result fits a signed 32-bit integer.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Inventory Discount TrackerOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Server ManagementRippling · OARippling interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
  • Economical TripAccenture · OAAccenture interview questions
  • Minimum Pile Reduction StepsAmerican Express · OAAmerican Express interview questions
  • Find Maximum Number of Subjects Passed (AS Intern, but it may apply to other interns) 🍋Amazon · OA
  • Maximum Production Within PowerZomato / Eternal · OAZomato / Eternal interview questions
  • Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
  • Compute Walking DistanceTikTok · OATikTok interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)

Roblox interview experiences

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int maximumTruckUnits(int[] boxes, int[] unitsPerBox, int capacity) {
        // write your code here
    }

}
Checking account…