FastPrepEqualize Piles of Boxes
Problems/Equalize Piles of Boxes

Equalize Piles of Boxes

Roblox logoRoblox● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The candidate's original screenshot gives the rule that lowers the highest pile, an example, and the limits. This version keeps them and leaves the input unchanged. Our version is about 100% the same as the reported question.

You have piles of boxes with heights in boxesInPiles. In one step, choose one pile whose height equals the current maximum and reduce it to the greatest current pile height strictly below that maximum. All other piles remain unchanged.

Return the minimum number of steps required to make all pile heights equal. If they are already equal, return 0. For this exercise, assume the input array must remain unchanged.

Function

pilesOfBoxes(boxesInPiles: int[]) → long

Examples

Example 1

boxesInPiles = [5,2,1]return = 3

Lower 5 to 2, then lower each of the two 2-height piles to 1.

Example 2

boxesInPiles = [7,7,7]return = 0

All piles are already equal.

Example 3

boxesInPiles = [3,1,3]return = 2

Lower each height 3 pile to 1, one pile per step.

Constraints

  • 1 <= boxesInPiles.length <= 200000.
  • 1 <= boxesInPiles[i] <= 2000000.
  • Return a signed 64-bit integer step count.

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
  • 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
  • Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
  • Sum of Pipeline Response TimesBloomberg LP · OABloomberg LP interview questions
  • Product of Subset MaximaArcesium · OAArcesium interview questions
  • REST API: Energy BarRippling · OARippling interview questions
  • Subsequences of ThreeTikTok · OATikTok interview questions
  • Get Average Standing 🍑Amazon · OA
  • Delete and Freeze GameRubrik · OARubrik interview questions

Interview reports that mention this question

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • 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 CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
  • Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public long pilesOfBoxes(int[] boxesInPiles) {
        // write your code here
    }

}
Checking account…