Minimize the Maximum Pages Allocated
Updated
Problem statement
You are given an integer array pages, where pages[i] is the number of pages in the i-th book. The books are arranged in their original order.
Allocate every book to exactly students students under these rules:
- Each student must receive at least one book.
- Each student receives one contiguous segment of books.
- The order of the books cannot change.
The load of a student is the total number of pages in that student's segment. Return the minimum possible value of the maximum student load.
If there are more students than books, return -1.
Function
minimizeMaximumPages(pages: int[], students: int) → longExamples
Example 1
pages = [12,34,67,90]students = 2return = 113Allocate books [12,34,67] to the first student and [90] to the second. Their loads are 113 and 90, so the maximum load is 113. No valid allocation has a smaller maximum.
Example 2
pages = [10,20,30,40]students = 2return = 60The allocation [10,20,30] and [40] has loads 60 and 40. Every other split produces a maximum load of at least 60.
Example 3
pages = [5,10,15]students = 4return = -1There are more students than books, so it is impossible to give every student a non-empty segment.
Constraints
1 <= pages.length <= 10^51 <= pages[i] <= 10^91 <= students <= 10^5
More Google Phone Screen questions
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
- Minimum Total Layover WaitPHONE SCREEN · Seen Nov 2026
- Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Aggressive CowsAmazon · PHONE SCREEN
- Maximize the Minimum Cone DistanceSumo Logic · PHONE SCREEN
- Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
- Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
- Minimize the Largest Part BeautyAdobe · PHONE SCREENAdobe interview questions
- Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
- Minimum Daily Printing LimitAgoda · ONSITE INTERVIEWAgoda interview questions
- Minimize the Longest Hike Between Rest StopsPinterest · ONSITE INTERVIEWPinterest interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Minimize Maximum Pilot WorkloadSpotnana · ONSITE INTERVIEWSpotnana interview questions