Problem Description
Given an array of integers A of size N and an integer B.
The College library has N books. The ith book has A[i] number of pages.
You have to allocate books to B number of students so that the maximum number of pages allocated to a student is minimum.
Calculate and return that minimum possible number.
NOTE: Return -1 if a valid assignment is not possible.
1 <= N <= 105
1 <= A[i], B <= 105
The first argument given is the integer array A. The second argument given is the integer B.
Return that minimum possible number.
A = [12, 34, 67, 90] B = 2Input 2:
A = [5, 17, 100, 11] B = 4
113Output 2:
100
There are two students. Books can be distributed in following fashion : 1) [12] and [34, 67, 90] Max number of pages is allocated to student 2 with 34 + 67 + 90 = 191 pages 2) [12, 34] and [67, 90] Max number of pages is allocated to student 2 with 67 + 90 = 157 pages 3) [12, 34, 67] and [90] Max number of pages is allocated to student 1 with 12 + 34 + 67 = 113 pages Of the 3 cases, Option 3 has the minimum pages = 113.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.