Minimum Tunnel Crossing Time
Updated
Problem statement
A group must pass through a tunnel of height tunnelHeight. Every person's height is strictly less than the tunnel height.
A crossing may contain either one person or two people:
- One person takes
soloTimeseconds. - Two people may cross together only when the sum of their heights is strictly less than
tunnelHeight; that crossing takespairTimeseconds.
Crossings happen one after another. Return the minimum total time needed for everyone to cross.
Function
minimumTunnelTime(heights: int[], tunnelHeight: int, soloTime: int, pairTime: int) → intExamples
Example 1
heights = [1,3,4,4,2]tunnelHeight = 9soloTime = 4pairTime = 6return = 16Pair heights 1 and 4, pair heights 3 and 4, and let the remaining person cross alone. The total is 6 + 6 + 4 = 16.
Example 2
heights = [1,3,4]tunnelHeight = 9soloTime = 4pairTime = 6return = 10One valid pair crosses in 6 seconds and the remaining person crosses in 4 seconds.
Constraints
heights.length >= 1.- Every height is positive and strictly less than
tunnelHeight. soloTimeandpairTimeare positive.
More Arcesium Online Assessment questions
- City Infection NumberOA · Seen Jul 2025
- Product of Subset MaximaOA · Seen Jul 2025
- Reconstruct the Root StreamOA · Seen Jul 2025
- Add DigitsOA · Seen Aug 2023
- Binary Tree Maximum Path SumOA · Seen Aug 2023
- Detect a Cycle in Directed Hate RelationshipsOA · Seen Aug 2023
- Reverse First K Characters in Every 2K BlockOA · Seen Aug 2023
- Robo Data Sharing DirectionOA · Seen Jul 2023
- Capital Gains Tax from TradesOA · Seen Feb 2021
- K-th Character in an Infinite StringOA · Seen Aug 2020
Similar questions at other companies
- 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
- Get Maximum PairsAmazon · OA
- Find Maximum GreatnessTwilio · OATwilio interview questions
- Binge WatchingVanguard · OAVanguard interview questions
- 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