Minimize Longest Daily Hike Duration
Given a route with N possible overnight stops and their cumulative travel times, determine the optimal placement of K overnight stops to minimize the longest single-day hiking duration across all K+1 days of the trip.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid June, 2026
Senior
You are the leader of a backpacking group. You plan to make K overnight stops during your (K+1)-day trip. You have a list of all possible overnight stops on your route. There are N possible stops numbered from 1 (the starting point) to N (the destination). Time to get to the possible stop number i from the starting point is T_i hours. To make hiking as balanced as possible, you want to make the longest daily hiking time (over all days) as small as possible. Write a program that finds minimal possible duration of the longest daily hike. // min_longest_day_hike(1, [0, 4, 7, 11, 12]) = 7
Hello Interview Premium
Your account is free and you can post anonymously if you choose.