Find the fastest hike pace for a club signing up in groups.
Unlock detailed company stats for this questionUpgrade
A hiking club signs up in groups. Each group is either two friends who insist on hiking together with pace1 and pace2, or a solo hiker with pace2 = 0. The guide takes whole groups only and needs at least M hikers. The hike moves at the pace of its slowest hiker. Return the fastest hike pace, or -1 if fewer than M hikers signed up.
Input: number of groups, then a 2D array int[N][2] of (pace1, pace2) per group, then M. Example 1: 1 group (5,0), M=1 -> 5 Example 2: 2 groups (6,4) (5,0), M=2 -> 4 Example 3: 3 groups (9,2) (7,0) (6,0), M=2 -> 6 (take the two solo hikers at 7 and 6 and leave the slow member of the pair out; picking the pair would cap the pace at 2).
Format · Online coding test on the HirePro platform, in Java.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
