Equalize Piles of Boxes
Updated
Problem statement
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[]) → longExamples
Example 1
boxesInPiles = [5,2,1]return = 3Lower 5 to 2, then lower each of the two 2-height piles to 1.
Example 2
boxesInPiles = [7,7,7]return = 0All piles are already equal.
Example 3
boxesInPiles = [3,1,3]return = 2Lower 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