Skip to main content
All Questions

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

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.