Efficient Janitor Trips
Updated
Problem statement
A janitor must carry every bag exactly once. For this exercise, weights are given in integer hundredths of a kilogram: 101 means 1.01 kg, and 300 means 3.00 kg. One trip carries at most 300 hundredths in total.
Return the minimum number of trips needed to carry all bags. You cannot split a bag, and you may group the bags in any order. Since every bag weighs at least 101, no trip can hold three bags. Do not change the input array. No bags requires zero trips.
Function
minJanitorTrips(weights: int[]) → intExamples
Example 1
weights = [101,101,300,270,199,230,170]return = 5Pair 101 with 199 and the other 101 with 170; 300, 270 and 230 travel alone.
Example 2
weights = [150,150,150,150]return = 2Two pairs weigh exactly 300 each.
Example 3
weights = []return = 0There are no bags to carry.
Constraints
0 <= weights.length <= 100000.101 <= weights[i] <= 300, with integer hundredths used to represent two-decimal precision.- Every bag must be included in exactly one trip, and every trip’s weight is at most
300.
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
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
- Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
- Minimum Machines for TasksExpedia · OAExpedia interview questions
- Find Minimum Possible SizeMathWorks · OAMathWorks interview questions
- Minimum Days to Watch All MoviesAdobe · OAAdobe interview questions
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
- Minimum Tunnel Crossing TimeArcesium · OAArcesium interview questions
- Get Maximum PairsAmazon · OA