FastPrepMinimize Maximum Pilot Workload
Problems/Minimize Maximum Pilot Workload

Minimize Maximum Pilot Workload

Spotnana logoSpotnana● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: This practice version is about an 88% match to the available interview report. The ordered flight durations, contiguous assignment to k pilots, and objective of minimizing the largest pilot workload come directly from the report. The callable interface, numeric limits, and examples were not shown, so those execution details are supplied consistently with the visible task.

You are given an integer array flights, where flights[i] is the duration of the i-th flight, and an integer k representing the number of available pilots.

Assign every flight to exactly one pilot while preserving the original flight order. Each pilot must receive one non-empty contiguous sequence of flights. A pilot's workload is the sum of the durations assigned to that pilot.

Return the minimum possible value of the maximum workload among all k pilots.

Function

minimizeMaximumPilotTime(flights: int[], k: int) → long

Examples

Example 1

flights = [10,20,30,40]k = 2return = 60

Assign [10,20,30] to one pilot and [40] to the other. Their workloads are 60 and 40. No partition can make the larger workload less than 60.

Example 2

flights = [5,1,2,7,3,4]k = 3return = 8

The groups [5,1,2], [7], and [3,4] have workloads 8, 7, and 7.

Constraints

  • 1 <= k <= flights.length <= 100000
  • 1 <= flights[i] <= 1000000000
  • The answer fits in a signed 64-bit integer.

More Spotnana problems

  • Optimal Card Game ScoreONSITE INTERVIEW · Seen Jul 2026
  • All OOne OperationsONSITE INTERVIEW · Seen Jul 2026
All Spotnana interview questionsSee Spotnana hiring insights
Saved
class Solution {
    public long minimizeMaximumPilotTime(int[] flights, int k) {
      // write your code here
    }

}
Checking account…